Subclasses in Python
Thomas Philips
tkpmep at hotmail.com
Thu Apr 29 20:02:58 EDT 2004
Perfect! But tell me, how did you know to use __name__? I typed
dir(object) and dir(Player) in IDLE, and in neither case did __name__
show up.
>>> dir(object) gives me
['__class__', '__delattr__', '__doc__', '__getattribute__',
'__hash__', '__init__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__str__']
dir(Player) gives me a few more things - the object's methods and
class variables, and some additional stuff: __dict__, __hash__,
__module__ and __weakref__. Neither sight nor sound of __name__ -
__module__is as close as I get to the magical __name__. What gives?
And, before I forget, thanks for all the help - I wouldn't have solved
it without you.
Thomas Philips
More information about the Python-list
mailing list