← Back to team overview

yade-users team mailing list archive

Re: [Question #407567]: the global cannot work

 

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

    Status: Answered => Open

xjin is still having a problem:
Thank you .My English is poor.
for my script is too long,so I do not give it out.I need the function as I refer it first. And I type the code :

x = 1
 y = 1
 print x # gives 1
 print y # gives 1

def func():
  global x # here you define that x is global, hence you can change it inside the function
  x = 2
  y = 2 # Python assumes that any name that is assigned to, anywhere within a function, is local to that function unless explicitly told otherwise

func()
 print x # ############gives 2--------------------------------Here I get 1,not 2.

So I want to try to get help, whether it is a bug in the YADE, not in
Python. My yade version is 2016.06a ,and my unbuntu is 16.04.

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