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
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
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*
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
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
>>
>>
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
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__ =
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