Class Methods with Python 2.1
Thomas Guettler
zopestoller at thomas-guettler.de
Tue Apr 23 11:23:11 EDT 2002
Is it possible to have methods in classes
which don't take a self argument, because
they only change attributes common to all
instances of a class?
class car:
available=["porsche", "volvo", "trabbi"]
def __init__(self, name):
if name not in available:
raise "Name not in available cars"
....
def add_available_car(name):
availalble.append(name)
One solutionn is to define this method
at module level. But that's not nice.
Unfortunately I have to stick to Python2.1
thomas
More information about the Python-list
mailing list