> I would like to know how would I evaluate a string expression in python.> For example, if i say:> >>> a = "3*2"> I want to do something to evaluate the variable 'a' to give me 6. How> can I do this?>
I think the "eval" built-in function is what you're after:
> >> a = "3*2"> >> eval(a)
6
http://docs.python.org/library/functions.html
_______________________________________________
Tutor maillist - Tutor@[...].org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor