← Back to team overview

yade-users team mailing list archive

[Question #407567]: the global cannot work

 

New question #407567 on Yade:
https://answers.launchpad.net/yade/+question/407567

my yade version is 2016.06a.
I write the codes like this:
---------------------------------------------------
x=1
globals()['x']=locals()['x']
def func():
    global x
    print x
    x = 2
    print x
 -------------------------------------------
Then I type " print x",I get result '1'
 Then I type "func()",I  get the result like this:

1
2
----------------------------------------------
At last, I type  " print x", but the result is also :"1", not "2".
I use global,but failed to change the x.
Can you help me?

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.