Quick Reference from module doc strings.

John Machin sjmachin at lexicon.net
Sun May 15 19:31:44 EDT 2005


Ron Adam wrote:
> Does anyone have suggestions on how to improve this further?

Not functionally (from me, yet). However if you can bear a stylistic
comment, do read on :-)

>          elif (isinstance(object,str)
>                  or isinstance(object,int)
>                  or isinstance(object,bool)
>                  or isinstance(object,tuple)
>                  or isinstance(object,list)
>                  or isinstance(object,dict)):

Since Python version 2.2, the 2nd arg of isinstance may be a tuple. You
could define this up front, with a meaningful name:

TYPES_WHICH_whatever = (str, int, bool, etc etc)

Cheers,
John




More information about the Python-list mailing list