By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,100 Members | 2,892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,100 IT Pros & Developers. It's quick & easy.

How to check for instances of a class

P: n/a
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 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 14 Nov 2006 11:00:53 -0800
er****@gmail.com 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
Nov 14 '06 #2

P: n/a
At Tuesday 14/11/2006 16:00, er****@gmail.com 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
Nov 14 '06 #3

P: n/a

That did the trick, thank you!

Nov 14 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.