G
Gnarlodious
Say this:
class tester():
_someList = [0, 1]
def __call__(self):
someList = self._someList
someList += "X"
return someList
test = tester()
But guess what, every call adds to the variable that I am trying to
copy each time:
test()
Can someone explain this behavior? And how to prevent a classwide
constant from ever getting changed?
-- Gnarlie
class tester():
_someList = [0, 1]
def __call__(self):
someList = self._someList
someList += "X"
return someList
test = tester()
But guess what, every call adds to the variable that I am trying to
copy each time:
test()
[0, 1, 'X'] test()
[0, 1, 'X', 'X']
Can someone explain this behavior? And how to prevent a classwide
constant from ever getting changed?
-- Gnarlie