[Python-Dev] None as a keyword / class methods
Guido van Rossum
guido@python.org
Tue, 28 Mar 2000 16:02:04 -0500
> A while back I put a lot of thought into how to support class methods
> and class attributes. I feel that I solved the problem in a fairly
> complete way though the solution does have some warts. Here's an
> example:
[...]
> Is anyone still with me?
>
> The crux of the problem is that in the current python class/instance
> implementation, classes dont have attributes of their own. All of
> those things that look like class attributes are really there as
> defaults for the instances. To support true class attributes a new
> name space must be invented. Since I wanted class objects to look
> like any other object, I chose to move the "instance defaults" name
> space under the underscore attribute. This allows the class's
> unqualified namespace to refer to its own attributes. Clear as mud,
> right?
>
> In case you are wondering, yes, the code above is a working example.
> I released it a while back as the 'objectmodule' and just updated it
> to work with Python-1.5.2. The update has yet to be released.
This looks like it would break a lot of code. How do you refer to a
superclass method? It seems that ClassName.methodName would refer to
the class method, not to the unbound instance method. Also, moving
the default instance attributes to a different namespace seems to be a
semantic change that could change lots of things.
I am still in favor of saying "Python has no class methods -- use
module-global functions for that". Between the module, the class and
the instance, there are enough namespaces -- we don't need another
one.
--Guido van Rossum (home page: http://www.python.org/~guido/)