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

Moshe Zadka Moshe Zadka <mzadka@geocities.com>
Sat, 25 Mar 2000 10:45:28 +0200 (IST)

On Thu, 23 Mar 2000 gvwilson@nevex.com wrote:

> If None becomes a keyword, I would like to ask whether it could be used to
> signal that a method is a class method, as opposed to an instance method:

I'd like to know what you mean by "class" method. (I do know C++ and Java,
so I have some idea...). Specifically, my question is: how does a class
method access class variables? They can't be totally unqualified (because
that's very unpythonic). If they are qualified by the class's name, I see
it as a very mild improvement on the current situation. You could suggest,
for example, to qualify class variables by "class" (so you'd do things
	class.x = 1), but I'm not sure I like it. On the whole, I think it
is a much bigger issue on how be denote class methods.

Also, one slight problem with your method of denoting class methods:
currently, it is possible to add instance method at run time to a class by
something like

class C:

def foo(self):

C.foo = foo

In your suggestion, how do you view the possiblity of adding class methods
to a class? (Note that "foo", above, is also perfectly usable as a plain

I want to note that Edward suggested denotation by a seperate namespace:

C.foo = foo # foo is an instance method
C.__methods__.foo = foo # foo is a class method

The biggest problem with that suggestion is that it doesn't address the
common case of defining it textually inside the class definition.

> I'd also like to ask (separately) that assignment to None be defined as a
> no-op, so that programmers can write:
>     year, month, None, None, None, None, weekday, None, None = gmtime(time())
> instead of having to create throw-away variables to fill in slots in
> tuples that they don't care about.

Currently, I use "_" for that purpose, after I heard the idea from Fredrik

Moshe Zadka <mzadka@geocities.com>. 
http://www.linux.org.il -- we put the penguin in .com