[Tutor] bug in eval() ? or doing something forbidden ?
Michael Janssen
Janssen at rz.uni-frankfurt.de
Mon May 10 08:21:24 EDT 2004
On Mon, 10 May 2004, Steckel, Ralf wrote:
> Dear Tutor,
>
> I'm trying to get the string representation of a string variable containing
> the unicode representation of a string via eval().
eval evaluates python expressions.
>>> eval("1+1")
2
>>> a="abc"
>>> eval("a")
'abc'
>>> eval("(a == 'abc')")
True
and things like this. "string representation" is done with repr():
>>> print repr(a)
'abc'
Michael
More information about the Tutor
mailing list