Re: something wrong with isinstance

2009-02-13 Thread Terry Reedy
Gabriel Genellina wrote: En Fri, 13 Feb 2009 08:43:03 -0200, Peter Otten <__pete...@web.de> escribió: class Type(type): ... def __instancecheck__(self, other): return True ... class A(metaclass=Type): pass ... class B: pass ... isinstance(B(), A) True See also http://www.python.or

Re: something wrong with isinstance

2009-02-13 Thread Gabriel Genellina
En Fri, 13 Feb 2009 08:43:03 -0200, Peter Otten <__pete...@web.de> escribió: Gabriel Genellina wrote: En Fri, 13 Feb 2009 08:07:58 -0200, Carl Banks escribió: But that brings up another very slight possibility, though not a very likely one in this case: the behavior of isinstance can be cus

Re: something wrong with isinstance

2009-02-13 Thread Peter Otten
Gabriel Genellina wrote: > En Fri, 13 Feb 2009 08:07:58 -0200, Carl Banks > escribió: > >> Well, the OP said he was using Python 3.0, where all classes are new- >> style classes. >> >> But that brings up another very slight possibility, though not a very >> likely one in this case: the behavior

Re: something wrong with isinstance

2009-02-13 Thread Gabriel Genellina
En Fri, 13 Feb 2009 08:07:58 -0200, Carl Banks escribió: Well, the OP said he was using Python 3.0, where all classes are new- style classes. But that brings up another very slight possibility, though not a very likely one in this case: the behavior of isinstance can be customized. It can h

Re: something wrong with isinstance

2009-02-13 Thread Carl Banks
On Feb 12, 10:49 am, redbaron wrote: > Don't really sure, but try to define your class as new-style one. > Like > class GeoMap(object): >    ... Well, the OP said he was using Python 3.0, where all classes are new- style classes. But that brings up another very slight possibility, though not a v

Re: something wrong with isinstance

2009-02-13 Thread Bruno Desthuilliers
maksym.ka...@gmail.com a écrit : Hi there. now i'm a complete newbie for python, and maybe my problem is stupid but i cannot solve it myself Others already addressed your problem (cf Paul and Diez answers). I'll just allow myself to point a couple other potential problems with your code: #

Re: something wrong with isinstance

2009-02-13 Thread Bruno Desthuilliers
redbaron a écrit : Don't really sure, but try to define your class as new-style one. isinstance() works as well with classic classes. -- http://mail.python.org/mailman/listinfo/python-list

Re: something wrong with isinstance

2009-02-12 Thread Diez B. Roggisch
maksym.ka...@gmail.com schrieb: Hi there. now i'm a complete newbie for python, and maybe my problem is stupid but i cannot solve it myself i have an object of class GeoMap which contains lists with objects of GeoMapCell (i will not explain what they should do, hope its not important). Then i wa

Re: something wrong with isinstance

2009-02-12 Thread Paul McGuire
On Feb 12, 12:26 pm, maksym.ka...@gmail.com wrote: > > Well the output of > > > print(type(obj)) > > print(str(obj)) > > was > > > > > Just looks well, isn't it? i have no idea what's wrong So then how do you know isinstance is evaluating to False? And why do you return None if it evals to True

Re: something wrong with isinstance

2009-02-12 Thread maksym . kaban
On 12 фев, 21:49, redbaron wrote: > Don't really sure, but try to define your class as new-style one. > Like > class GeoMap(object): >    ... Sorry, it didn't work -- http://mail.python.org/mailman/listinfo/python-list

Re: something wrong with isinstance

2009-02-12 Thread redbaron
Don't really sure, but try to define your class as new-style one. Like class GeoMap(object): ... -- http://mail.python.org/mailman/listinfo/python-list

Re: something wrong with isinstance

2009-02-12 Thread maksym . kaban
> Here's a crazy idea out of left field.  Just before calling > isinstance, why not try: > > print(type(obj)) > print(str(obj)) > > This may illuminate the unexpected behavior, you'll find out just what > obj has in it. > > -- Paul Well the output of > print(type(obj)) > print(str(obj)) was J

Re: something wrong with isinstance

2009-02-12 Thread Paul McGuire
On Feb 12, 11:53 am, maksym.ka...@gmail.com wrote: > Hi there. > now i'm a complete newbie for python, and maybe my problem is stupid > but i cannot solve it myself > > i have an object of class GeoMap which contains lists with objects of > GeoMapCell (i will not explain what they should do, hope i

something wrong with isinstance

2009-02-12 Thread maksym . kaban
Hi there. now i'm a complete newbie for python, and maybe my problem is stupid but i cannot solve it myself i have an object of class GeoMap which contains lists with objects of GeoMapCell (i will not explain what they should do, hope its not important). Then i want to serialize these objects to j