newbee I have an object how to check what's his class?

Gabriel Genellina gagsl-py at yahoo.com.ar
Fri Nov 10 17:42:45 EST 2006


At Friday 10/11/2006 18:05, consternation wrote:

>def __init__
>  self.mem={}
>I googled a way how  to add elements to dict,  I have read the code not the
>description below

self.mem[key] = value

I strongly suggest you read some introductory Python docs, like 
http://docs.python.org/tut/tut.html or http://www.diveintopython.org

>isinstance(x,X)
>True                :-)
>type(x) is X
>False                :( ??
>__main__.X
>X
>  temporarily it solves my probblems I'm just curious why type can't handle
>the test.

You still didn't show enough code, but I bet that X is an old-style 
class, that is, you wrote:
class X: blablabla
instead of
class X(object): blablabla
For old-style class instances, type(x) is InstanceType, not the actual class.


-- 
Gabriel Genellina
Softlab SRL 

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar



More information about the Python-list mailing list