Hacker News
points by sakesun 2 days ago | 0 comments
I've been doing things in Python for over 20 years. Only recently I learn that I can do this.

    >>> Dog.__bases__ = (Cat,)
    >>> isinstance(dog, Dog)
    True
    >>> isinstance(dog, Cat)
    True
    >>>
[–] pjmlp 1 day ago
Smalltalk, Self, Common Lisp, Ruby as well, no big deal in regards to JIT code.
[–] gregdeon 2 days ago
This is wild. Is it part of Python's specification, or an implementation detail of CPython?
[–] sakesun 2 days ago
As far as I understand, CPython implementation is THE specification. Some billions dollar ERP system firmly rely on this behavior, btw.
[–] gregdeon 1 day ago
Yeah, I was afraid you would say that.
[–] sakesun 1 day ago
Just check with pypy and Graalpy. Both support this as well.
[–] dcrazy 1 day ago
Is the question whether multiple base classes are part of Python’s spec, or if the ability to assign to `__class__` is part of the spec?