newbie-name mangling?

Diez B. Roggisch deets at nospam.web.de
Tue Dec 13 16:15:02 EST 2005


> 
> Could someone provide an example of the above or direct me to a page
> where it is used.


class MangledMembers:

     def __init__(self):
         self.__mangled_propertyname = "fooo"


mm = MangledMembers()

try:
     print mm.__mangled_propertyname
except AttributeError:
     print "It's private!"

print "But I can get it:", mm._MangledMembers__mangled_propertyname


Look at the code, and carefully reread the paragraph in the tutorial.

Regards,

Diez




More information about the Python-list mailing list