Python is DOOMED! Again!

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Jan 22 09:57:45 EST 2015


Chris Angelico wrote:

> Hold on a moment, how often do you really do this kind of thing with
> "might be one of them or a sequence"? 

isinstance(obj, one_class_or_tuple_of_classes)
issubclass(cls, one_class_or_tuple_of_classes)
mystr.startswith(prefix_or_tuple_of_prefixes)
mystr.endswith(suffix_or_tuple_of_suffixes)
template % one_string_or_tuple_of_strings  # or a dict :-)


I'm not suggesting that the specific example is a good one, but the
principle is sound.



-- 
Steven




More information about the Python-list mailing list