annotate wsgraph/utils.py @ 8:f1f7a505e0d0

__contains__ method
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 10 Dec 2012 17:08:02 -0800
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
f1f7a505e0d0 __contains__ method
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 """
f1f7a505e0d0 __contains__ method
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 utility functions that should be in core python
f1f7a505e0d0 __contains__ method
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
f1f7a505e0d0 __contains__ method
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
f1f7a505e0d0 __contains__ method
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 def isiterable(instance):
f1f7a505e0d0 __contains__ method
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 try:
f1f7a505e0d0 __contains__ method
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 iter(instance)
f1f7a505e0d0 __contains__ method
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 return True
f1f7a505e0d0 __contains__ method
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 except TypeError:
f1f7a505e0d0 __contains__ method
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 return False