[Python-Dev] None as a keyword / class methods
gvwilson@nevex.com
gvwilson@nevex.com
Thu, 23 Mar 2000 12:10:16 -0500 (EST)
[The following passed the Ping test, so I'm posting it here]
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:
class Ping:
def __init__(self, arg):
...as usual...
def method(self, arg):
...no change...
def classMethod(None, arg):
...equivalent of C++ 'static'...
p = Ping("thinks this is cool") # as always
p.method("who am I to argue?") # as always
Ping.classMethod("hey, cool!") # no 'self'
p.classMethod("hey, cool!") # also selfless
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. I think both behaviors are readable;
the first provides genuinely new functionality, while I often found the
second handy when I was doing logic programming.
Greg