Many problems I've ran into in Python have been related to not having something in Unicode. Is there any good reason to not use Unicode by default? I understand needing to translate something in ASCII, but it seems to be the exception and not the rule.
I know Python 3 uses Unicode for all strings. Should this encourage me as a developer to unicode() all my strings?
Generally, I'm going to say "no" there's not a good reason to use string over unicode. Remember, as well, that you don't have to call unicode() to create a unicode string, you can do so by prefixing the string with a lowercase u like u"this is a unicode string".
In Python 2.x:
str object is basically just a sequence of bytes.unicode object is a sequence of characters.Knowing this, it should be easy to choose the correct type:
unicode.str (in many other languages you'd use byte[] here).In Python 3.x the type str is a string of characters, just as you would expect. You can use bytes if you want a sequence of bytes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With