Global var editing from another script in Python -


i'm trying increment python global var script, doesn't seem updating. doing wrong here?

i run func() multiple times during script execution , never seems update globval

script 1:

def func():     script2 import globval     global globval     print "glob val " + str(globval)     globval = globval + 1 

script 2 (different file):

global globval globval = 1 

yes, are doing wrong (answering first question)

you should move from script2 import globval top of script2 value being imported each time 1. after moving import top, globval variable should update.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -