Python 2.8?
Python 2.8?
Posted Jan 14, 2017 5:45 UTC (Sat) by lsl (subscriber, #86508)In reply to: Python 2.8? by ddevault
Parent article: Python 2.8?
You can redefine terms all you want but there are operations I can reasonably do on bytes that the literature calls "string manipulation". I'm talking about things like splitting on 0x0A ('\n') or 0x2F ('/') bytes. Those are reasonable things to do if whatever you're working on defines them as a reasonable thing to do. I don't have to somehow "decode" the byte string before I can manipulate it. In fact, I cannot possibly decode it as I have no idea (nor a desire to know) what any of these bytes are supposed to mean. The only thing I need to know is that I can legitimately split them upon encountering a '/' byte.
Super simple stuff, until you bring Python 3 into the mix with its desire to enforce specific encodings where none were agreed upon.
Posted Jan 14, 2017 10:54 UTC (Sat)
by rschroev (subscriber, #4164)
[Link]
>>> b'abc/def/ghi'.split(b'/')
I think this didn't work in 3.0; I don't know when that changed. IIRC at the same time other string manipulations were implemented fro bytestrings.
split() works on bytestrings now
[b'abc', b'def', b'ghi']
>>> b'abc def ghi'.split()
[b'abc', b'def', b'ghi']