[Python-Dev] None as a keyword / class methods
Barry A. Warsaw
bwarsaw@cnri.reston.va.us
Thu, 23 Mar 2000 13:57:00 -0500 (EST)
>>>>> "gvwilson" == <gvwilson@nevex.com> writes:
gvwilson> If None becomes a keyword, I would like to ask whether
gvwilson> it could be used to signal that a method is a class
gvwilson> method, as opposed to an instance method:
It still seems mildly weird that None would be a special kind of
keyword, one that has a value and is used in ways that no other
keyword is used. Greg gives an example, and here's a few more:
def baddaboom(x, y, z=None):
...
if z is None:
...
try substituting `else' for `None' in these examples. ;)
Putting that issue aside, Greg's suggestion for static method
definitions is interesting.
class Ping:
# would this be a SyntaxError?
def __init__(None, arg):
...
def staticMethod(None, arg):
...
p = Ping()
Ping.staticMethod(p, 7) # TypeError
Ping.staticMethod(7) # This is fine
p.staticMethod(7) # So's this
Ping.staticMethod(p) # and this !!
-Barry