Variable Value Is Determined By Function Call
This is probably weird but I would like to declare a variable without a fixed value, but 'linked' in some way to the result of a function. The goal is for the end user to manipulat
Solution 1:
an_int
is an object. It won't change its value unless you change it. However, you could change the way the object is represented:
from random import randint
classRandomFun(object):
def__str__(self):
returnstr(randomfun())
defrandomfun():
return randint(1, 100)
an_int = RandomFun()
print an_int
print an_int
yields (something like)
57
19
Post a Comment for "Variable Value Is Determined By Function Call"