Issue
I have a program written like this
class test:
def test2():
def test3():
global tester
print(tester)
tester = 'working'
test3()
test.test2()
I am fully capable of using the script as is without the class and cannot remove the class and the current structure because I am referencing this class in another script which is threaded as a separate instance.
The only and main problem is the inability to get the global function to work for a function in a function in a class.
Solution
Seems like every time I can't find an answer whenever I ask 5 seconds later I found the solution.
class test:
def test2():
global tester
def test3():
global tester
print(tester)
tester = 'working'
test3()
test.test2()
this works added tester as a global in what normally would be called reference before assignment.
Answered By - Brecht Corbeel Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.