tag:blogger.com,1999:blog-11683713.post111172835670556183..comments2024-01-12T21:16:50.520-08:00Comments on Spyced: How well do you know Python, part 1Jonathan Ellishttp://www.blogger.com/profile/11003648392946638242noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-11683713.post-1113517451601167532005-04-14T15:24:00.000-07:002005-04-14T15:24:00.000-07:00From the 1.4 release notes: "Any identifier of the...From the 1.4 release notes: "Any identifier of the form __spam (at least two leading underscores, at most one trailing underscore) is now textually replaced with _classname__spam, where classname is the current class name with leading underscore(s) stripped. This mangling is done without regard of the syntactic position of the identifier, so it can be used to define class-private instance and class variables, methods, as well as globals, and even to store instance variables private to this class on instances of other classes. Truncation may occur when the mangled name would be longer than 255 characters. Outside classes, or when the class name consists of only underscores, no mangling occurs."Jonathan Ellishttps://www.blogger.com/profile/11003648392946638242noreply@blogger.comtag:blogger.com,1999:blog-11683713.post-1113514146774978202005-04-14T14:29:00.000-07:002005-04-14T14:29:00.000-07:00Not a Python Expert.Can someone please explain thi...Not a Python Expert.<BR/><BR/>Can someone please explain this more? Name mangling? Does that mean the double underscores?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-11683713.post-1112375775296320222005-04-01T09:16:00.000-08:002005-04-01T09:16:00.000-08:00Correct.Correct.Jonathan Ellishttps://www.blogger.com/profile/11003648392946638242noreply@blogger.comtag:blogger.com,1999:blog-11683713.post-1112375558973387432005-04-01T09:12:00.000-08:002005-04-01T09:12:00.000-08:00OK, I'll guess... name mangling in the function do...OK, I'll guess... name mangling in the function doesn't match the name mangling in the exec'd statement (which doesn't know about its function scope), so you get a NameError.Ian Bickinghttps://www.blogger.com/profile/10921115783730718101noreply@blogger.com