Re: Unexpected behaviour of getattr(obj, __dict__)

2006-02-16 Thread Christos Georgiou
On Tue, 14 Feb 2006 22:24:12 -0500, rumours say that "Terry Reedy" <[EMAIL PROTECTED]> might have written: > id(Parrot.f) == id(Parrot.f) >> True > id(Parrot.__dict__) == id(Parrot.__dict__) >> True > >A wrapper is created and passed to id() which returns an int object while >releasing th

Re: Unexpected behaviour of getattr(obj, __dict__)

2006-02-14 Thread Terry Reedy
"Carl Banks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > But wait, it gets weirder. Not weird at all. Just an artifact of CPython's storage recycling algorithm. id(Parrot.f) == id(Parrot.f) > True id(Parrot.__dict__) == id(Parrot.__dict__) > True A wrapper is crea

Re: Unexpected behaviour of getattr(obj, __dict__)

2006-02-14 Thread Steven D'Aprano
On Tue, 14 Feb 2006 13:03:17 +0100, bruno at modulix wrote: > Steven D'Aprano wrote: >> I came across this unexpected behaviour of getattr for new style classes. >> Example: >> >> >class Parrot(object): >> >> ... thing = [1,2,3] >> ... >> >getattr(Parrot, "thing") is Parrot.thing >

Re: Unexpected behaviour of getattr(obj, __dict__)

2006-02-14 Thread Fredrik Lundh
Steven D'Aprano wrote: > >class Parrot(object): > >> > >> ... thing = [1,2,3] > >> ... > >> > >getattr(Parrot, "thing") is Parrot.thing > >> > >> True > >> > >getattr(Parrot, "__dict__") is Parrot.__dict__ > >> > >> False > > > > > > hint: > getattr(object, '__dict__') > > >

Re: Unexpected behaviour of getattr(obj, __dict__)

2006-02-14 Thread Carl Banks
Raymond Hettinger wrote: > Steven D'Aprano wrote: > > I came across this unexpected behaviour of getattr for new style classes. > > Example: > > > > >>> class Parrot(object): > > ... thing = [1,2,3] > > ... > > >>> getattr(Parrot, "thing") is Parrot.thing > > True > > >>> getattr(Parrot, "__dic

Re: Unexpected behaviour of getattr(obj, __dict__)

2006-02-14 Thread Steven D'Aprano
On Tue, 14 Feb 2006 04:11:52 -0800, Raymond Hettinger wrote: > Steven D'Aprano wrote: >> I came across this unexpected behaviour of getattr for new style classes. >> Example: >> >> >>> class Parrot(object): >> ... thing = [1,2,3] >> ... >> >>> getattr(Parrot, "thing") is Parrot.thing >> True >

Re: Unexpected behaviour of getattr(obj, __dict__)

2006-02-14 Thread Raymond Hettinger
Steven D'Aprano wrote: > I came across this unexpected behaviour of getattr for new style classes. > Example: > > >>> class Parrot(object): > ... thing = [1,2,3] > ... > >>> getattr(Parrot, "thing") is Parrot.thing > True > >>> getattr(Parrot, "__dict__") is Parrot.__dict__ > False > > I would

Re: Unexpected behaviour of getattr(obj, __dict__)

2006-02-14 Thread bruno at modulix
Steven D'Aprano wrote: > I came across this unexpected behaviour of getattr for new style classes. > Example: > > class Parrot(object): > > ... thing = [1,2,3] > ... > getattr(Parrot, "thing") is Parrot.thing > > True > getattr(Parrot, "__dict__") is Parrot.__dict__ > > False

Unexpected behaviour of getattr(obj, __dict__)

2006-02-14 Thread Steven D'Aprano
I came across this unexpected behaviour of getattr for new style classes. Example: >>> class Parrot(object): ... thing = [1,2,3] ... >>> getattr(Parrot, "thing") is Parrot.thing True >>> getattr(Parrot, "__dict__") is Parrot.__dict__ False I would have expected that the object returned by get