Quiz: Difference between implicit and explicit inheritence

Pavol Lisy pavol.lisy at gmail.com
Mon Aug 28 09:27:30 EDT 2017


On 8/28/17, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> In Python 3, what's the difference between these two classes?

> # implicitly inherit from object
> class Spam:
>     ...
>
> # explicitly inherit from object
> class Spam(object):
>     ...
>
> If you sense a trick question, you're right :-)
>

object = int  # this could be trick
...
class Spam(object):
    ...

dis.dis show difference too, next line is just for "class
Spam(object):" version:
     LOAD_GLOBAL              0 (object)

So nor rebinding object nor rebinding __builtin__.object affect "class
Spam:" version.



More information about the Python-list mailing list