To make a method or attribute private

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Jan 20 10:15:42 EST 2013


On Sun, 20 Jan 2013 06:52:32 -0800, iMath wrote:

[snip many dozens of lines of irrelevant text]

> what's the meaning of 'object' in
> class A(object)
> and
> class B(object) ?


Please trim your replies. We don't need to scroll past page after page of 
irrelevant text which we have already read.

"object" is the name of the base class defining common methods used by 
all new classes. In Python 2, you should always subclass object, unless 
you are subclassing something else. In Python 3, subclassing object is 
automatic, whether you write it or not.

In Python 2, if you fail to subclass object, you get an "old-style 
class", and features like property, classmethod, staticmethod, super and 
multiple inheritance may not work at all, or be buggy.



-- 
Steven



More information about the Python-list mailing list