16 ms·
did they further improve backwards compatibility? Neither trolling nor beating dead horses: I recently wanted to do some screen capture and needed tkinter, wh
by singularity2001 9y ago
did they further improve backwards compatibility?
Neither trolling nor beating dead horses:
I recently wanted to do some screen capture and needed tkinter, which of course has different imports for py2 and py3. adding library aliases would help. I honestly wished people would use transitional deprecation warnings more often to educate about changed apis.
As long as 50% of tensorflow projects are still in Python 2 it is always a pain to encounter Python 3.
```
try:
from urllib2 import urlopen
from urllib import urlretrieve
except ImportError:
from urllib.request import urlopen, urlretrieve
```
- orf 9y agoHave you tried the 'six' library? It does what you describe, as well as paving over many py2/py3 differences
- singularity2001 9y agoTangentially heard of it. Thanks, will try. Does it add py2 conventions to py3 or Does it add py3 conventions to py2 ?
- viraptor 9y agoNeither. It adds a wrapper in `six.moves` to various modules which moved between py2/3. It will not automatically fix existing code, but it does allow you to use one import line.
- orf 9y agoNeither, it just let's you write code that runs on 2 and 3 quite easily, by hiding import differences and changes to builtins. It's worth it if you are distributing code that has to run on 3 and 2, but if your upgrading your existing 2 code base it's not that great.
- kevin_thibedeau 9y agoIs 15 years to prepare still not long enough to migrate your code incrementally? You can get Py2 into a nearly-ready-for-Py3 state with just a little effort stretched over whatever horizon you desire. Beating a dead horse doesn't do anything about your stagnant code base.
- singularity2001 9y agoit's not about migrating old code bases, it's about encountering other peoples tensorflow/ubuntu code and often ending up in unnecessary(!) hickups.
- orf 9y agoI used to be quite militant about this, but you have to get that often business goals don't align. You can often do it on the side, during other changes, but convincing your manager that it's worth it is a hard problem.
- brylie 9y agoNP-hard.
- mjevans 9y agoNo, because they did a bunch of things that make automated porting not work well and provides a ton of developer friction. I'm willing to live with Python's space related insanity. Mandating that indenting is meaningful. Mandating a best practice of using spaces instead of tabs for indent* (which makes tab width matter). Mandating that a tab equals 4 spaces instead of 8. (Honestly, I REALLY hate this, most of the Windows developers are happy with the space usage koolaid, let us have a default of tab equals 8 spaces of indent.) Those are ALL, REALLY ANNOYING, but lint tools can save me. What will bite me for as long as Python 3 exists, and maybe Python 4, is how they handle Unicode support and encoded outputs. Pretty much the ENTIRE rest of the computing world does one of two things. 1) Doesn't care what the encoding is, and flings around non-validated 8 bit sequences of data. 2) Does care, and defaults to assuming well formed UTF-8 data-streams for text data, BUT still doesn't do anything to enforce it UNLESS ASKED. Most importantly invalid data streams just continue flowing through the processing tools until they reach a point where a human has designated they're willing to care and /do/ something about it. If Python 4 wants to 'fix' Unicode support: * Use a binary sequence base storage class with metadata tags. > Length (in bytes, in 'display length', and maybe in 'codepoint length') > encoding* (including if normalized and how so) > If the encoding has been validated. * Support automatic coercion between standard encodings * Allow user defined helpers for custom conversions * Make all input/output default to UTF-8** but permit raw output of such types without validation or re-encoding, just like every other UNIX tool that knows what an encoding is.