The format which I'm using to execute some code based on which class the variable 'tester' is appears not to be working. How can I write the code such that the variable 'var' in the class 'testClass()' is changed
I've tried changing the format from "if tester == testClass():" to "if testClass() in [tester]:", but neither work nor return errors. Changing 'var = second' to 'var = "second"' doesn't appear to help either, and neither does removing any brackets.
The code is as follows:
class fillClass():
fill = True
class testClass():
var = "first"
filler = True
tester = testClass()
oldVar = tester.var
print(oldVar,"is older variable")
second = "second"
if tester == testClass():
class testClass():
var = second
filler = True
tester = testClass()
newVar = tester.var
print(newVar,"is newer variable")
I would expect the output
first is older variable
second is newer variable
>>>
but the actual output is
first is older variable
first is newer variable
>>>
How can I fix this issue?
Many thanks!
Aucun commentaire:
Enregistrer un commentaire