[Tutor] Beginner question (variables, namespaces...) (fwd)
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Sat Apr 8 05:09:18 CEST 2006
---------- Forwarded message ----------
Date: Fri, 7 Apr 2006 21:05:33 -0600
From: Jesse <intermezzoooh at gmail.com>
To: Danny Yoo <dyoo at hkn.eecs.berkeley.edu>
Subject: Re: [Tutor] Beginner question (variables, namespaces...)
I tried redefining the "higher-order" variables as functions, but it didn't
quite work. Here's a simplified example:
var1 = 2
def timestwo(x):
return x*2
var2 = timestwo(var1)
print var1, var2
var1 = 3
print var1, var2
This results in the output:
2, 4
3,4
..which is not what I'm aiming for. Maybe I'll have to follow Bob's advice
and just store all of the variable assignments in a function, and then call
the function every time I change one of the variables (based on user input).
I could still leave the higher-order variables as functions as per your
advice, but that alone doesn't seem to do the trick. Unless I've missed
something.
Jesse
More information about the Tutor
mailing list