Re: Bypassing __setattr__ for changing special attributes

2007-02-27 Thread Facundo Batista
Ziga Seilnacht wrote: object.__setattr__(f, '__class__', Bar) f.__class__ is Bar > True Interesting, but... why I must do this? And, I must *always* do this? With Foo and Bar like the OP coded (just two new style classes, f is instance of Foo), see this: >>> f <__main__.Foo object at

Re: Bypassing __setattr__ for changing special attributes

2007-02-20 Thread Fuzzyman
On Feb 20, 12:57 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Mon, 19 Feb 2007 23:18:02 -0800, Ziga Seilnacht wrote: > > George Sakkis wrote: > >> I was kinda surprised that setting __class__ or __dict__ goes through > >> the __setattr__ mechanism, like a normal attribute: > > >> class Foo(o

Re: Bypassing __setattr__ for changing special attributes

2007-02-20 Thread George Sakkis
On Feb 20, 3:54 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On 20 fév, 05:39, "George Sakkis" <[EMAIL PROTECTED]> wrote: > > > I was kinda surprised that setting __class__ or __dict__ goes through > > the __setattr__ mechanism, like a normal attribute: > > But __class__ and __dict___ *are*

Re: Bypassing __setattr__ for changing special attributes

2007-02-20 Thread George Sakkis
On Feb 20, 7:57 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Mon, 19 Feb 2007 23:18:02 -0800, Ziga Seilnacht wrote: > > George Sakkis wrote: > >> I was kinda surprised that setting __class__ or __dict__ goes through > >> the __setattr__ mechanism, like a normal attribute: > > >> class Foo(ob

Re: Bypassing __setattr__ for changing special attributes

2007-02-20 Thread Steven D'Aprano
On Mon, 19 Feb 2007 23:18:02 -0800, Ziga Seilnacht wrote: > George Sakkis wrote: >> I was kinda surprised that setting __class__ or __dict__ goes through >> the __setattr__ mechanism, like a normal attribute: >> >> class Foo(object): >> def __setattr__(self, attr, value): >> pass >> >>

Re: Bypassing __setattr__ for changing special attributes

2007-02-20 Thread [EMAIL PROTECTED]
On 20 fév, 05:39, "George Sakkis" <[EMAIL PROTECTED]> wrote: > I was kinda surprised that setting __class__ or __dict__ goes through > the __setattr__ mechanism, like a normal attribute: But __class__ and __dict___ *are* 'normal' attributes... -- http://mail.python.org/mailman/listinfo/python-l

Re: Bypassing __setattr__ for changing special attributes

2007-02-19 Thread Ziga Seilnacht
George Sakkis wrote: > I was kinda surprised that setting __class__ or __dict__ goes through > the __setattr__ mechanism, like a normal attribute: > > class Foo(object): > def __setattr__(self, attr, value): > pass > > class Bar(object): > pass > > >>> f = Foo() > >>> f.__class__ =

Bypassing __setattr__ for changing special attributes

2007-02-19 Thread George Sakkis
I was kinda surprised that setting __class__ or __dict__ goes through the __setattr__ mechanism, like a normal attribute: class Foo(object): def __setattr__(self, attr, value): pass class Bar(object): pass >>> f = Foo() >>> f.__class__ = Bar >>> print f.__class__ is Foo True Is