5 ms·
Since Python 3 can detect this case and accurately determine the user intent, it could have just executed the statement as if it were written with parentheses.
by not2b 6y ago
Since Python 3 can detect this case and accurately determine the user intent, it could have just executed the statement as if it were written with parentheses. Had they done that alone, they would have significantly decreased the number of short Python scripts that broke during the transition. Or they could have made a --permissive flag that would do this.
- Pet_Ant 6y agoThat removes the nudge. People should update their materials.
- epistasis 6y agoIf you think that, do you think Word should start refusing to open .doc documents at some point? Code is sometimes alive and changing, and sometimes an artifact. Requiring that code become alive after being an artifact carries significant risks. One might say "code should never be unmaintained" but I think that ignores the reality of limited resources that all of us deal with.
- jolux 6y agoWell, we can either have continuous innovation and improvement with proper security, or we can have long-term support for code that is unmaintained, but it currently seems impossible to have both. I don’t think anyone would consider the .doc format a paragon of design elegance or security.
- BlueTemplar 6y agoI'm willing to bet latest Word will have issues opening earliest Word documents ?
- abiogenesis 6y agoIt is phenomenally good: https://news.ycombinator.com/item?id=21451713 https://news.ycombinator.com/item?id=21451713
- SteveNuts 6y agoOr people can just read the error and fix their code.
- cedilla 6y agoHaving print as a statement was a mistake with a lot of downsides (see https://www.python.org/dev/peps/pep-3105/ https://www.python.org/dev/peps/pep-3105/ for the rationale). It would take quite a lot of effort to offer the new print function and the old print statement at the same time, and it would require either a lot of special cases or renaming the new print function. And there's really no upside. If the only legacy thing in your script is the use of print statements, that's trivial to fix by hand or with one of the automatic converters.
- captainmuon 6y ago> And there's really no upside. Yes there is, the print function is the biggest syntactic incompatibility. Besides the (optional) u marker for unicode strings that they reintroduced later. Most of the other difference (like changed packages) are semantic. You would have been able to import and run Python 2 in Python 3, maybe with a couple of "if"s or some magic in the module loader. Breaking compatibility like this felt petty and deliberate and made it really hard to have one codebase target both python 2 and 3 (temporarily).
- Wowfunhappy 6y agoBut as the GP mentioned, it can be fixed automatically. In this specific case I think it's a non-issue. If python3 was limited (or limited except in very niche cases) to changes that could be made programmatically, we wouldn't be in this situation. Everyone would just run 2to3.py and never look back.
- odonnellryan 6y agoIt's also extremely easy to fix.
- zestyping 6y agoPython is a teaching language. One of its strengths is that it can be your first language and still be one you use professionally a decade later. A "trivial" obstacle to a seasoned programmer can be an insurmountable obstacle to a beginner.