FAQ: How do I calculate what quoted strings and numbers mean?
p.lavarre at ieee.org
p.lavarre at ieee.org
Mon Nov 20 14:20:37 EST 2006
> but the os module isn't very far away
I see Python defines some evals that apparently don't import os, such
as:
int('0x100'[2:], 0x10)
float('1.23e+4')
binascii.unhexlify('4142')
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{}
escape.
Is then a "slow and dangerous" eval my only reasonably concise choice?
More information about the Python-list
mailing list