Feb-13-2018, 09:06 AM
Function attributes and global variables seem quite similar:
Can someone explain what the main difference is between the two?
Also PyCharm gives me two warnings in the editor (no errors in output area):
"Global variable 'ok' is undefined at the module level"
"Cannot find reference 'bye' in 'function'"
def hi():
hi.bye = 50 # function attribute
hi()
def testing():
global ok # global variable
ok = 50
testing()
print(hi.bye + ok) # output -> 100 Can someone explain what the main difference is between the two?
Also PyCharm gives me two warnings in the editor (no errors in output area):
"Global variable 'ok' is undefined at the module level"
"Cannot find reference 'bye' in 'function'"
