unicode string literals and "u" prefix
"Martin v. Löwis"
martin at v.loewis.de
Mon Nov 8 17:03:01 EST 2004
nico wrote:
> But if I understand well, prefixing a unicode string literal with 'u'
> will eventually become obsolete ( in python 3.0 ? ), as all strings
> will be unicode in a more or less distant future.
I think you misunderstand. It might become deprecated (in the sense
of becoming redundant yet still possible); in any case, this future
is certainly distant (maybe five or ten years).
> So, to write "clean" script code, is it a good idea to write a script
> like this ?
No. Do use Unicode literals whenever you can.
> ( I know the -U option can disappear in a next python version, but is
> not better to delete the "-U" option at the top of the scripts than
> all "u" unicode prefixes, when python will consider all strings as
> unicode ?... )
As you say: *when*. Current Python doesn't, and explicit is better than
implicit. There is no plan yet as to when (or even if) to release Python
3.
> It seems that "print" encodes by default with the shell current
> encoding.
Yes, it should.
> Do you think that a script written like this will still work with
> python 3.0 ?
Most certainly. Even when string literals become Unicode by default,
u""-prefixes will still be accepted - most likely so for ten or
twenty years.
Regards,
Martin
More information about the Python-list
mailing list