initializing private members via exec

Jeff Shannon jeff at ccvcorp.com
Fri Nov 16 13:21:02 EST 2001


Curtis Jensen wrote:

> Why session below give me an error? Is there some rule against
> initializing private data members inside an exec function?  Is there an
> equivalant way of initializing private members?  Thanks.

Not using exec?

Obviously what you've shown is a trivial example, intended to demonstrate
what you see as the problem.  But more likely, the real problem is your
decision to use exec.  ;)  Exec and eval() are very powerful, but most of
the time that someone tries to use them, there's a simpler, safer, easier
way to do the same thing.  Try finding that way.  (Maybe post the problem
that you're trying to solve by using exec?)

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list