¡@

Home 

python Programming Glossary: isinstance

Differences between isinstance() and type() in python

http://stackoverflow.com/questions/1549801/differences-between-isinstance-and-type-in-python

between isinstance and type in python What are the differences between these two.. if type b in types.StringTypes do_something_else Using isinstance if isinstance a dict do_something if isinstance b str or isinstance.. in types.StringTypes do_something_else Using isinstance if isinstance a dict do_something if isinstance b str or isinstance b unicode..

In Python, how do I determine if an object is iterable?

http://stackoverflow.com/questions/1952464/in-python-how-do-i-determine-if-an-object-is-iterable

substitution. Duck typing avoids tests using type or isinstance . Instead it typically employs the EAFP Easier to Ask Forgiveness.. particular functionality for example import collections if isinstance e collections.Iterable # e is iterable share improve this..

Flatten (an irregular) list of lists in Python

http://stackoverflow.com/questions/2158395/flatten-an-irregular-list-of-lists-in-python

x result for el in x if hasattr el __iter__ and not isinstance el basestring result.extend flatten el else result.append el.. boost the performance. def flatten l for el in l if isinstance el collections.Iterable and not isinstance el basestring for.. for el in l if isinstance el collections.Iterable and not isinstance el basestring for sub in flatten el yield sub else yield el..

Suggestions for a Cron like scheduler in Python?

http://stackoverflow.com/questions/373335/suggestions-for-a-cron-like-scheduler-in-python

conv_to_set obj # Allow single integer to be provided if isinstance obj int long return set obj # Single item if not isinstance.. obj int long return set obj # Single item if not isinstance obj set obj set obj return obj # The actual Event class class..