FAQ: How do I calculate what quoted strings and numbers mean?

p.lavarre at ieee.org p.lavarre at ieee.org
Mon Nov 20 20:20:37 CET 2006

> but the os module isn't very far away

I see Python defines some evals that apparently don't import os, such

int('0x100'[2:], 0x10)

Does Python also define an eval that doesn't import os for literal
string args?

For example, suppose someone gives me source strings like
repr('\a\r\n') when I need byte strings like '\a\r\n'.
http://docs.python.org/ref/strings.html lists the escapes that need
eval'ling, especially the comparatively heavy and Python-specific \N{}

Is then a "slow and dangerous" eval my only reasonably concise choice?

More information about the Python-list mailing list