Identify object class

Carl Banks imbosol at aerojockey.invalid
Tue Oct 14 16:03:46 EDT 2003


Nicolas Fleury wrote:
> Hi,
>        How do we quickly identify in Python if an object is of a specific 
> class *or* is of a class deriving directly or indirectly from that class?


You want the isinstance built-in function.  Example:

    if isinstance(obj,cls): do_whatever()


> BTW, don't you think this newsgroup has a lot of activity and it should 
> be time to make other newsgroups like comp.lang.python.windows, etc?


Good idea!  I propose the following:

comp.lang.python.misc
comp.lang.python.gui
comp.lang.python.networking
comp.lang.python.dev
comp.lang.python.lisp-envy


-- 
CARL BANKS                   http://www.aerojockey.com/software

As the newest Lady Turnpot descended into the kitchen wrapped only in
her celery-green dressing gown, her creamy bosom rising and falling
like a temperamental souffle, her tart mouth pursed in distaste, the
sous-chef whispered to the scullery boy, "I don't know what to make of
her." 
          --Laurel Fortuner, Montendre, France 
            1992 Bulwer-Lytton Fiction Contest Winner




More information about the Python-list mailing list