3 ms·
Well the lighter solution and more Pythonic solution is strong typing. If a Unicode string and a byte string could not be combined then the problem would not e
by gardentheory 14y ago
Well the lighter solution and more Pythonic solution is strong typing. If a Unicode string and a byte string could not be combined then the problem would not exist AFAIK. For example "a" + 1 is an error, why is u"a" + "s" not an error?
- xerula 14y agoBut b"s" + "a" is an error in Py3.
- qznc 14y agoThis just gives a different error message. It does not help to find the error source. The programmer would probably just try to fix it via str(u"a")+"s" or u"a" + unicode("s").
- masklinn 14y ago> For example "a" + 1 is an error, why is u"a" + "s" not an error? "a" + b"s" is an error in Python 3.
- gardentheory 14y agoSorry, that was my point. Strengthening the types in python3 solves the problem without static typing being needed at all.
- masklinn 14y agook. Static types solve it earlier though, especially for little-exercised code paths which could be forgotten or missed in testing.