[Python-Dev] RE: Hot-To Guide for Descriptors - Nits! :-)
pinard at iro.umontreal.ca
Wed Jan 21 21:33:38 EST 2004
> On Wed, 2004-01-21 at 20:24, François Pinard wrote:
> > If there is no base class, then "if there's a global variable named
> > __metaclass__, it is used." So my guess would be that adding a mere
> > __metaclass__ = type
> > in global scope for a module would make all classes be "new-style",
> > without the need to subclass them from object explicitly.
> Unless you define a class that inherits from a base class defined in
> another module.
I thought about this of course. This is no problem in our case, since
these other modules will have their `__metaclass__ = type' themselves.
> I prefer to inherit from object, because it is more explicit, and
> avoids possible confusion when some classes have classic bases.
A `__metaclass__ = type' at the beginning of a module is explicit enough
to my eyes. If I can demonstrate that this does not harm, it will
become a convention here to include this line in each and every module
for all in-house projects, and we should be done with classic classes.
Unless we sub-class classic classes from the Python library, I do not
know how frequently we do that. By the way :-), I presume there are
plans for the Python library to progressively switch to new-style
classes whenever possible? If not, should they be?
François Pinard http://www.iro.umontreal.ca/~pinard
More information about the Python-Dev