Py3.3 unicode literal and input()

David M Chess chess at us.ibm.com
Mon Jun 18 12:58:37 EDT 2012


> If you (the programmer) want a function that asks the user to enter a
> literal at the input prompt, you'll have to write a post-processing for
> it, which looks for prefixes, for quotes, for backslashes, etc., and
> encodes the result.  There very well may be such a decoder in the Python
> library, but input does nothing of the kind.

As it says at the end of eval() (which you definitely don't want to use 
here due to side effects):

See ast.literal_eval() for a function that can safely evaluate strings 
with expressions containing only literals. 

DC


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120618/d43ee8a9/attachment.html>


More information about the Python-list mailing list