compile(unicode) & source encoding
Martin v. Löwis
martin at v.loewis.de
Mon Dec 1 14:14:34 EST 2003
"Denis S. Otkidach" <ods at strana.ru> writes:
> Why we have to choose one particular encoding and not just assume
> all strings to be unicode?
Assume the source code reads
source = u"""
f=open("/etc/passwd","a")
f.write("news:x:9:13:News system:/etc/news:/bin/bash\n")
"""
What data type should the argument of f.write have, in this example?
If the answer is not <type 'str'>, you would cause many compatibility
problems.
> Surely. But there is no way to emulate "python -U" behavior for
> compiled piece of code.
However, python -U does not currently work. When it does, exposing it
separately to compile() might be reasonable. OTOH, the current
behaviour might be sufficient: If -U is passed, strings created in
compile would automatically be Unicode strings - which is the case
today.
Regards,
Martin
More information about the Python-list
mailing list