← Back to team overview

yade-users team mailing list archive

Re: [Question #266939]: Stop conditions failed

 

Hello Diego,
there are two options. Either proper use of 'global' keyword in Python (use
it *in* the function, not in the beginning of the script), or you can use
__builtin__ module (be careful not to overwrite some other important
variables).
Let us know if it works
cheers
Jan

###########################
import __builtin__

someGlobalVariable = 1
someOtherGlobalVariable = 1
__builtin__.someGlobalVariable = someGlobalVariable

def increment():
  __builtin__.someGlobalVariable += 1
    #
  global someOtherGlobalVariable
  someOtherGlobalVariable += 1
    #
  print 'builtin',__builtin__.someGlobalVariable
  print 'global ',__builtin__.someGlobalVariable

O.engines = [PyRunner(iterPeriod=1,command="increment()"),]
O.run(10)
#############################



2015-05-15 1:36 GMT+02:00 Diego Sotro <question266939@xxxxxxxxxxxxxxxxxxxxx>
:

> Question #266939 on Yade changed:
> https://answers.launchpad.net/yade/+question/266939
>
> Diego Sotro posted a new comment:
> ** this variable in final()
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to     : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help   : https://help.launchpad.net/ListHelp
>

Follow ups

References