[Tutor] Evaluating a string expression

Tim Golden mail at timgolden.me.uk
Thu Nov 5 14:25:12 CET 2009


Mkhanyisi Madlavana wrote:
> Hi Everyone,
> 
> 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'm afraid that your question doesn't pass the basic "Have I Googled it?"
test. I stuck "evaluate a string expression in python" into Google and got:

http://www.google.co.uk/#q=evaluate+a+string+expression+in+python

Does any of that help?

TJG


More information about the Tutor mailing list