Like in:
u'Hello'
My guess is that it indicates "unicode", is it correct?
If so, since when is it available?
Like in:
u'Hello'
My guess is that it indicates "unicode", is it correct?
If so, since when is it available?
You're right.
http://docs.python.org/tutorial/introduction.html#unicode-strings
It's been syntax since 2.0.
My guess is that it indicates "unicode", is it correct?
Yes.
If so, since when is it available?
Python 2.x.
(In Python 3.x the strings use Unicode by default and there's no need for the u
prefix.)
The following should help:
http://docs.python.org/library/functions.html#unicode
http://www.amk.ca/python/howto/unicode (skip down to "Python's Unicode Support" if you're already familiar with Unicode principles)
All strings meant for humans should use u"".
I found that the following mindset helps a lot when dealing with Python string. All python manifest strings should use u""
syntax, the ""
syntax is for byte arrays, only.
Before the bashing begins, let me explain. Most Python programs start out with using ""
for strings. But then they need to support docs off the internet so they start using "".decode
and all of a sudden they are getting exceptions everywhere about decoding this and that - all because of the use of ""
for strings. In this case, Unicode does act like a virus and will wreak havoc.
But, if you follow my rule, you won't have this infection (because you will already be infected).