initializing private members via exec

Michael Hudson mwh at
Fri Nov 16 11:36:51 CET 2001

Curtis Jensen <cjensen at> writes:

> Why session below give me an error? 

Because name mangling is done by the compiler, basically.

> Is there some rule against initializing private data members inside
> an exec function?  

(aside: "inside an exec function" suggests confusion)

Well, it doesn't work, does it?  So probably, yes.

> Is there an equivalant way of initializing private members?

exec 'self._Foo__monty = 1'?  Note the parentheses are an anachronism wrt

Not using double underscores?


  This is the fixed point problem again; since all some implementors
  do is implement the compiler and libraries for compiler writing, the
  language becomes good at writing compilers and not much else!
                                 -- Brian Rogoff, comp.lang.functional

More information about the Python-list mailing list