Mapping operator tokens to special methods
John Machin
sjmachin at lexicon.net
Thu Feb 24 15:59:39 EST 2005
On 24 Feb 2005 10:57:58 -0800, jamesthiele.usenet at gmail.com wrote:
>I was starting to write a dictionary to map operator strings to their
>equivalent special methods such as:
>{
> '+' : 'add',
> '&' : 'and_'
>}
>
>The idea is to build a simple interactive calculator.
>
>and was wondering if there is already something like this builtin?
>>> eval('1+2')
3
More information about the Python-list
mailing list