Python 3 isinstance
google at mrabarnett.plus.com
Thu Jan 15 18:26:45 CET 2009
Lambert, David W (S&T) wrote:
> I have use case, needn't be dynamic, and it's not hard to enclose set as
> tuple. But I also write (for example)
> __all__ = 'this that other'.split()
> string_list = 'evenOneWord'.split()
> instead of
> __all__ = 'this','that','imTiredOfMistypingCommasAndQuotes'
> if not isinstance(o,set_of_handled_types):
> raise TypeError('call blessed programmer, this cannot occur')
> if isinstance(o,set_of_handle_types-treat_differently):
> elif isinstance(o,treat_differently):
> elif etc.
You could write a Python source processor like 2to3.py which would
replace 'this that other'.split() with ['this', 'that', 'other']. In
fact, you could even write abbreviations such as /this that other/
and then use the script to expand them!
More information about the Python-list