I have been trying to postpone the creation of an object inside a function. I am aware that if you want to modify a global variable you must use the global keyword. But, if I run that code:
testvar = 0
class myobject(object):
asd = 'whatever'
def afunc():
global testvar
testvar = myobject()
After executing afunc(), testvar is equal to 0.
Why ???
New contributor
Gael is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.