3 ms·
Pick a Python 3 feature and let us know how you would implement it in Python 2.
by verbatim 11y ago
Pick a Python 3 feature and let us know how you would implement it in Python 2.
- Grue3 11y agoEasy. Feature: print function. Implementation: from __future__ import print_function Yes, that magical, backwards-incompatible, print function has been in Python 2 all along! Feature: unicode strings Implementation: from __future__ import unicode_literals Amazing! The magical, backwards-incompatible unicode strings backported to Python 2 with one single line. I could go on and on.
- orf 11y ago> Amazing! The magical, backwards-incompatible unicode strings backported to Python 2 with one single line. Except it's not even slightly close to that is it. unicode_literals is something completely different. How about removing old style classes? Is `class x:` old style or new style in Python 2, in this imaginary interpreter of yours? How about the default object comparison being sane in Python 3. How about the changes to builtins returning iterables over lists? How about the import system being more sane? How about removing backticks? How about actually handling the unicode differences? I could go on and on, and I hope your answer is not 'well we just need more __future__ imports don't we'.