[IronPython] Statefulness of CompiledCode
sanxiyn at gmail.com
Mon May 26 18:39:14 CEST 2008
2008/5/27 Greg Parker <greg.parker at brovada.com>:
> Here is a condensed version of the python script to illustrate the problem.
> I run this from a C# application which executes the CompiledCode ten times.
> When the length of "fooListClassVariable" is printed, it increases to ten.
> I would have expected to see one for every iteration.
> class SomeClass:
> fooListClassVariable = ;
> def AddFoo(self):
> print str(len(self.fooListClassVariable))
If you want to see 1 printed for every iteration, do:
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