newbee I have an object how to check what's his class?
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Fri Nov 10 12:14:02 EST 2006
In <ej2b34$9nk$1 at ultra60.mat.uni.torun.pl>, consternation wrote:
> Thank You for reply but ....
> I found solution suggested by You in a tutorial yesterday. For some reason
> it doesn't work in my case.
>
> code:
> #mem-dictionary in Y class for storing objects
> #Y doesn't inherit from X
> for (i,v) in self.mem.items():
> print " isinstance(x,X)"
> print isinstance(v,X)
> print "type(x) is X"
> print type(v) is X
> print v.__class__.__name__
> print v.__class__
>
> result:
> isinstance(x,X)
> False
> type(x) is X
> False
> <type 'list'>
> list
Define "doesn't work". Obviously lists are not instances of your `X`
class. So where's the problem? What did you expect and why?
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list