private class members and hasattr
Erik Max Francis
max at alcyone.com
Fri Jan 23 05:47:19 EST 2004
Dragos Chirila wrote:
> Why hasattr method doesn't return 1(true) for private member '__prop3'
> ??
>
> I tested it with Python 2.2.1 and 2.1.3 .
Because a prefix double underscore (without a suffixed double
underscore, anyway) mangles the identifier with the intention of it
being private. That is to say, trying to access a __private name from
another class is a good indication that you're doing something you're
not supposed to be doing.
--
__ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
\__/ I do not promise to consider race or religion in my appointments.
I promise only that I will not consider them. -- John F. Kennedy
More information about the Python-list
mailing list