> sage: x = "this is x" > sage: y = "this is y" > sage: z = "this is z" > sage: def f(): > ....: print x > ....: y = "new value" > ....: print y > ....: global z > ....: z = "new value" > ....: print z > ....: > > sage: f() > this is x > new value > new value > > sage: x, y, z > ('this is x', 'this is y', 'new value')
Yes it's true, that's the behavior I was referring to. My problem was actually that I couldn't print a global variable inside a function before I made an assignment to it; the error was something like "Cannot istantiate a local variable before assigning it." and I didn't understand why I had to assign locally a global variable which had already been assigned globally. Anyway the keyword "global" solved my problem. -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org