How to check for instances of a class

Discussion in 'Python' started by erokar@gmail.com, Nov 14, 2006.

  1. Guest

    Traversing a list of variables, I need to check wheter an element in
    the list is an instance of a (user defined) class. What cind of
    comparison operator can I use? Can't seem to find this in the
    documentation. I anyone have an example it is much appreciated.
     
    , Nov 14, 2006
    #1
    1. Advertising

  2. On 14 Nov 2006 11:00:53 -0800
    wrote:

    > Traversing a list of variables, I need to check wheter an element in
    > the list is an instance of a (user defined) class. What cind of
    > comparison operator can I use? Can't seem to find this in the
    > documentation. I anyone have an example it is much appreciated.


    Use isinstance() <http://docs.python.org/lib/built-in-funcs.html>.

    You need something like

    >> isinstance(list_element, your_class)



    Dennis
     
    Dennis Benzinger, Nov 14, 2006
    #2
    1. Advertising

  3. At Tuesday 14/11/2006 16:00, wrote:

    >Traversing a list of variables, I need to check wheter an element in
    >the list is an instance of a (user defined) class. What cind of
    >comparison operator can I use? Can't seem to find this in the
    >documentation. I anyone have an example it is much appreciated.


    isinstance


    --
    Gabriel Genellina
    Softlab SRL

    __________________________________________________
    Correo Yahoo!
    Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
    ¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
     
    Gabriel Genellina, Nov 14, 2006
    #3
  4. Guest

    That did the trick, thank you!
     
    , Nov 14, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. david

    multiple class instances

    david, Nov 30, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    375
    morganm1
    Apr 16, 2004
  2. PJ6
    Replies:
    3
    Views:
    377
  3. E11
    Replies:
    1
    Views:
    4,789
    Thomas Weidenfeller
    Oct 12, 2005
  4. John Wohlbier
    Replies:
    2
    Views:
    369
    Josiah Carlson
    Feb 22, 2004
  5. Replies:
    8
    Views:
    470
    James Stroud
    Jan 29, 2009
Loading...

Share This Page