[Python-Dev] None as a keyword / class methods

Donald Beaudry Donald Beaudry <donb@init.com>
Tue, 28 Mar 2000 17:56:03 -0500


Guido van Rossum <guido@python.org> wrote,
> This looks like it would break a lot of code.

Only if it were to replace the current implementation.  Perhaps I
inadvertly made that suggestion.  It was not my intention.  Another
way to look at my post is to say that it was intended to point out why
we cant have class methods in the current implementation... it's a
name space issue.

> 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.

Right.  To get at the unbound instance methods you must go through the
'unbound accessor' which is accessed via the underscore.

If you wanted to chain to a superclass method it would look like this:

    class child(parent):
        def do_it(self, x):
            z = parent._.do_it(self, x)
            return z

> Also, moving the default instance attributes to a different
> namespace seems to be a semantic change that could change lots of
> things.

I agree... and that's why I wouldnt suggest doing it to the current
class/instance implementation.  However, for those who insist on
having class attributes and methods I think it would be cool to settle
on a standard "syntax".

> I am still in favor of saying "Python has no class methods -- use
> module-global functions for that".

Or use a class/instance implementation provided via an extension
module rather than the built-in one.  The class named 'base' shown in
my example is a class designed for that purpose.

> Between the module, the class and the instance, there are enough
> namespaces -- we don't need another one.

The topic comes up often enough to make me think some might disagree.

--
Donald Beaudry                                     Ab Initio Software Corp.
                                                   201 Spring Street
donb@init.com                                      Lexington, MA 02421
                  ...So much code, so little time...