On Fri, 03 Dec 2010 19:28:00 +, kj wrote:
> This was the first surprise for me: assigning to the __class__ attribute
> not only isn't vetoed, but in fact changes the instances class:
>
> Oh-ky...
>
> First question: how kosher is this sort of class transmutation through
> assignment to _
kj writes:
> >>> class Spam(object): pass
>
> Now I define an instance of Spam and an instance of Spam's superclass:
> >>> x = Spam()
> >>> y = Spam.__mro__[1]() # (btw, is there a less uncouth way to do this???)
There's the `__bases__' attribute, which is simply a tuple of the
class's direct su
kj writes:
> I have a couple of questions regarding assigning to an instance's
> __class__ attribute.
>
> The first is illustrated by the following interaction. First I
> define an empty class:
>
class Spam(object): pass
> ...
>
> Now I define an instance of Spam and an instance of Spam's
On 12/3/10 1:28 PM, kj wrote:
I have a couple of questions regarding assigning to an instance's
__class__ attribute.
The first is illustrated by the following interaction. First I
define an empty class:
class Spam(object): pass
...
Now I define an instance of Spam and an instance of Spam'
I have a couple of questions regarding assigning to an instance's
__class__ attribute.
The first is illustrated by the following interaction. First I
define an empty class:
>>> class Spam(object): pass
...
Now I define an instance of Spam and an instance of Spam's superclass:
>>> x = Spam()