Private variable

Deokhwan Kim deokhwankim at hotmail.com
Fri Jul 6 03:23:59 CEST 2001


In 9.6 Private Variables, Python Tutorial:

  Notice that code passed to exec, eval() or evalfile() does not consider the
  classname of the invoking class to be the current class; this is similar to
  the effect of the global statement, the effect of which is likewise
  restricted to code that is byte-compiled together. The same restriction
  applies to getattr(), setattr() and delattr(), as well as when referencing
  __dict__ directly.

I have found an explanation of the second statement in Language Reference.

  the global is a directive to the parser. It applies only to code parsed at
  the same time as the global statement. In particular, a global statement
  contained in an exec statement does not affect the code block containing the
  exec statement, and code contained in an exec statement is unaffected by
  global statements in the code containing the exec statement. The same applies
  to the eval(), execfile() and compile() functions.


But I don't know what the first and third statements mean in regard to private
variables.  Can you explain them as examples if possible?



More information about the Python-list mailing list