On Mon, 01 Dec 2008 07:43:44 -0800, Emanuele D'Arrigo wrote: > On Nov 29, 5:21 am, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> This is a side-effect of name-mangling. Double-underscore names are >> only mangled when they are referred to directly as attributes, not when >> they are passed to setattr, getattr etc. Those functions don't do any >> name mangling. > > Ah! That make sense! Thank you! > > It's a bit of an obscure thing right now. I don't see mention of it in > the description of the setattr/getattr built-ins: > > http://docs.python.org/library/functions.html > > Wouldn't be good to have a hint of the issue there?
Not really. You seem to assume that name mangling always happens unless the docs say it doesn't. That's backwards. Name mangling *never* happens except where the docs say it does. Hence I can tell you that self.__dict__['__name'] will fail to find a name-mangled attribute self.__name without even trying it, because I know dictionary lookups don't do name-mangling either. -- Steven -- http://mail.python.org/mailman/listinfo/python-list