4 ms·
I've said this before and have said it again: Python3 got rid of the wrong string type. With `bytes` it was obvious that byte length was not the same as $whate
by o11c 11mo ago
I've said this before and have said it again: Python3 got rid of the wrong string type.
With `bytes` it was obvious that byte length was not the same as $whatever length, and that was really the only semi-common bug (and was mostly limited to English speakers who are new to programming). All other bugs come from blindly trusting `unicode` whose bugs are far more subtle and numerous.
- Flimm 11mo agoI strongly disagree. Python 2 had no bytes type to get rid of. It had a string type that could not handle code points above U+00FF at all, and could not handle code points above U+007F very well. In addition, Python 2 had a Unicode type, and the types would get automatically converted to each other and/or encoded/decoded, often incorrectly, and sometimes throwing runtime exceptions. Python 3 introduced the bytes type that you like so much. It sounds like you would enjoy a Python 4 with only a bytes type and no string type, and presumably with a strong convention to only use UTF-8 or with required encoding arguments everywhere. In both Python 2 and Python 3, you still have to learn how to handle grapheme clusters carefully.
- seanhunter 11mo agoPython 3 didn't get rid of bytes though. If you want to manipulate data as bytes you absolutely can do that. https://docs.python.org/3/library/stdtypes.html#binary-sequence-types-bytes-bytearray-memoryview https://docs.python.org/3/library/stdtypes.html#binary-seque... "The core built-in types for manipulating binary data are bytes and bytearray."
- o11c 11mo agoThose are arrays of integers, not of bytes. Most bytes are character-ish, which only python2's bytes acknowledged. Additionally, python2 supported a much richer set of operations on its bytes type than python3 does.