logoalt Hacker News

sakesun • today at 12:25 AM • 1 reply • view on HN

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
    >>>

Replies

gregdeon • today at 2:52 AM

This is wild. Is it part of Python's specification, or an implementation detail of CPython?

➕ show 1 reply