I was curious, so I did some searches on this topic for you and found these pages:
- https://news.ycombinator.com/item?id=18155134
- http://www.catb.org/esr/faqs/practical-python-porting/
The second link in particular notes:
The reason that things are much easier with all ASCII data is that practically every Unicode encoding in existence maps bytes 0x00…0x7f to the corresponding code points, so byte strings and Unicode strings that contain the same all-ASCII data are basically equivalent, even semantically. What usually trips people up with non-ASCII data is that the semantic meaning of bytes in the range 0x80…0xff changes from one encoding to another.
But, thinking like a systems programmer again, for many purposes the semantic meaning of bytes 0x80…0xff doesn’t matter. All that matters is that those bytes are preserved unchanged by whatever operations are done. Typical operations like tokenizing strings, looking for markers indicating particular types of data, etc. only need to care about the meaning of bytes in the range 0x00…0x7f; bytes in the range 0x80…0xff are just along for the ride.
So the trick for beating Python 3 strings into submission is to put in encoding and decoding calls where you need to, choosing a single-byte encoding that doesn’t mutate 0x80…0xff. There are many of these; most of the Latin-{1…6} sequence (aka ISO-8859-1…10) is has this property. What you do not want to do is pick utf-8 or any of the multibyte Asian encodings. Latin-1 will do fine; in fact it has an advantage over the others in memory consumption, which we’ll describe below.
Whether depending on this is actually correct or not is beyond me, but it seems like people have actually been using that pass-through behavior in practice and put it into things like Python2 -> 3 migration guides.
The first link suggests that the seemingly undefined ranges are valid as C0 and C1 control codes which may be why it doesn’t throw errors.
I wrote something like this before for academic researchers to load data sets on display walls by using their cellphones. I approached it by building a simple website. When the user logs in, they’d see a table of entries (from a directory listing on a shared file server that they could drop their data sets onto) and could click a button that made a form post to the server which caused it to run whichever programs were needed to load the data set they wanted (or run a couple of other handy commands – like turning the monitors on/off, etc).
You can do something like that too in Python if you want:
subprocess
library. If you know how to launch the programs you want from the command line, it shouldn’t be too hard to figure out how to do it from Python by reading the documentation. It will take some more effort to figure out how to interact with it (e.g. to stop it from user input) without blocking your script, but this can be done.localhost
(possibly plus a port) or from on your LAN by putting the IP of your computer into the address bar.os.listdir
, or something more involved like tracking the entries with a spreadsheet or database or JSON file that lets you associate custom metadata with each entry (like a custom name to show or an icon to display or when it was last launched, etc.)<
into<
that are needed for HTML output and also repeat patterns using entries from lists you provide to build the rows of tables and such for you.Good luck and have fun!