How to avoid calling same function multiple times python? -


i simulate problem in python, i'm new python programming. wanted check whether if there way avoid calling same function(return same value every time) multiple times.

eg:

def fun():     return calling_another_fun()# return same value eg: 200  var = fun()  var1 = fun() var2 = fun()  print "calling first time"+str(var) print "calling second time"+str(var1) print "calling third time"+str(var2) 

is there way call fun() @ 1 place and

assignment can bind same object multiple names.

a = b = c = 42 

note names point same object, if object mutable appear change each of names.

>>> = b = [] >>> a.append(none) >>> b [none] 

Comments