dunder-docs (was Python is DOOMED! Again!)

Chris Angelico rosuav at gmail.com
Tue Feb 3 18:39:41 EST 2015


On Wed, Feb 4, 2015 at 10:32 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> No, I'm saying Python should behave differently.
>
> Python:
>
>    >>> class A:
>    ...    def f(self):
>    ...       print("f")
>    ...    def g(self):
>    ...       print("g")
>    ...
>    >>> a = A()
>    >>> a.__class__.f = a.__class__.g
>    >>> a.f()
>    g
>
> In my preferred semantics, a.f() would print
>
>    >>> a.f()
>    f

Yeeeouch. So either it has to actually copy everything in on
instantiation (stupid cost for the tiny chance that it'll actually
ever matter), or else have some kind of versioning that means that it
knows that 'a' was created from the pre-changed class.

What's the advantage?!?

ChrisA



More information about the Python-list mailing list