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 the wrapper back to

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 getattr 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 hint: getattr(object,

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 have expected that the

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 getattr(Parrot,

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, __dict__) is Parrot.__dict__

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__') dictproxy object at 0x2ab2ff30 That doesn't answer the

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 True getattr(Parrot,

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 created and passed