[IronPython] Statefulness of CompiledCode

Greg Parker greg.parker at brovada.com
Mon May 26 18:56:32 CEST 2008


Actually I do want a class variable as I described.  By design  
"fooListClassVariable" should be shared for all instances of "SomeClass" 
during one execution.  However, I don't want it to remember the value on 
subsequent calls to "compiledScript.Execute()", which is what is 
happening.  I would expect that every time I execute the CompiledCode it 
would not retain any state information about the last time it was 
executed.  This would be sort of like executing a c# application twice, 
and seeing class variables initialized to the values from the first 
execution.  Maybe I am misusing the CompiledCode class.

> If you want to see 1 printed for every iteration, do:
>
> class SomeClass:
>   def __init__(self):
>     self.fooListClassVariable = []
>
> etc. You want it to be an instance variable (which is initialized
> every time new instance is created), not a class variable (which is
> shared by all instances of the class).
>
>   




More information about the Ironpython-users mailing list