What's the difference between VAR and _VAR_?
Erik Max Francis
max at alcyone.com
Fri Sep 9 16:03:52 EDT 2005
S. D. Rose wrote:
> I can't get the value of the variable (out of the class function) if it has
> two leading underscores.
Sure you can if you want it hard enough; it's just mangled.
>>> class C: __x = 1
...
>>> dir(C)
['_C__x', '__doc__', '__module__']
>>> c = C()
>>> dir(c)
['_C__x', '__doc__', '__module__']
>>> c._C__x
1
--
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
What is now prov'd was once only imagin'd.
-- William Blake
More information about the Python-list
mailing list