Steven Bethard wrote:
[...]M.E.Farmer wrote:
there are no variables in python
As M.E.Farmer mentioned, you can't remove underscores on special method names like __init__. However, when you're declaring an instance variable, e.g.:While it's unnecessary in most cases, I'd like to point out that the mechanism is mostly to avoid inadvertent clashes in the object namespace.
self.__xyz = True
then you're choosing the name here, so you can name it whatever you want. The only reason to use leading double-underscores is if you want Python to name-mangle the variable so it's not (easily) accessible from subclasses. In most cases, this is unnecessary.
So, if you are designing a class explicitly to be subclassed, that's when the use of mangled names can pay off.
Of course, if the subclass implementor actually *does* need access to your instance variables they will curse you if you've mangled them.
unwrapping-that-mangling-isn't-pretti-ly y'rs - steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list