1

I am trying to make a function find out the original expression which was used as an argument to a function. Example:

def fun(var):
    exp_var = <some magic>
    print "%s = %s"%(exp_var, var)

so that:

>>> fun(4.5+2*2)

will print

4.5+2*2 = 8.5

I think there should be a way using python's inspect module but I couldn't find how.

jonrsharpe
  • 107,083
  • 22
  • 201
  • 376
tal
  • 830
  • 7
  • 18

0 Answers0