class inheritance when not defined
Andrej Viktorovich <viktorovichandrej at gmail.com> writes:
> I found several class creation samples:
> class ExampleClass1:
> class ExampleClass2(object):
> What is difference between them?
Very little difference.
In Python 3, both create classes that inherit from one other class,
In Python 2, the first creates ?ExampleClass1? that has no parent class,
and doesn't work in the standard type hierarchy. The ?ExampleClass2?
class inherits from ?object? and does participate in the standard type
This is, broadly, one of the good reasons to abandon Python 2: you can
forget about the special case of classes that don't inherit from
?object?. In Python 3, they don't exist because every class inherits
ultimately from ?object?.
> Who is the father of ExampleClass1 ?
No-one, since classes do not have gender. (The convention is to use the
gender-neutral ?parent? to refer to that relationship.)
\ ?We cannot solve our problems with the same thinking we used |
`\ when we created them.? ?Albert Einstein |