6 ms·
> So it broke the experience for all first time users. To be fair, Python 3 provides a very clear error message if you try to use print as a statement, althoug
by norrius 6y ago
> So it broke the experience for all first time users.
To be fair, Python 3 provides a very clear error message if you try to use print as a statement, although I don't know when exactly that was added:
$ echo 'print "Hello World"' > test.py && python3 test.py
File "test.py", line 1
print "Hello World"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Hello World")?
- NullPrefix 6y ago>To be fair, Python 3 provides a very clear error message To be fair, nobody reads error or warning messages.
- mylons 6y agothen those people are helpless? you can lead a horse to water.
- kshacker 6y agoI agree with the parent actually. My first python program was a json read and print something. 4 lines, maybe 5. I had a need to parse json and print something specific and I suspected I would be able to do it in python. After 4 hours, I was able to and I felt happy. This is not to complain about that 4 hours. But when I think back at that 4 hours and how much time will it take to do it today, it reminds me of all the learnings. Is it load or loads? Which one is from file? What is a json object? Do I need to quote? If so how? Why does it work with the small block but not the big block? Is it the nesting? Am I doing something wrong? I think the same is true of hello world. Hello world is a newbie presumably who has not written a single line of code. Well you copy and paste and it does not run. Yes the error is there but hey I copied working code : did I install something wrong? Should I check some website? It says it is python but is it? You can't imagine the questions that will come to a newbie. We need to be mindful of this rather than have a stack overflow mindset.
- deleted 6y ago[deleted]
- archgoon 6y agoThis is largely due to conditioning of over 30+ years of bad error messages. The program exited with error code -2 Error MS1337 occurred Something went wrong. Contact your Administrator Ideally; error codes should provide information about how to fix the problem (which python in this case does). That falls on the developer side of things (and may not be possible in many cases). Learning that error messages are useful and can solve your problem, and de-training the reflexive "This message won't help me", lies on the end user side of things (assuming the devs did their part).
- masklinn 6y ago> Ideally; error codes should provide information about how to fix the problem (which python in this case does). That falls on the developer side of things (and may not be possible in many cases). Rust generally tries to do that, although the fixes it proposes tend to lack context, and can thus lead you into the wrong direction entirely (e.g. once upon a time it would tell you to go and implement a trait on your type when the issue was that you'd forgotten a trait bound on a generic type, it still kinda says that but now there's a snippet which adds the trait bound so it's less error-inducing).
- bleepblorp 6y agoPython itself has a habit of contributing to this long history of extremely hostile messages. If run in interactive mode, the Python interpreter takes its cues from vi and deliberately frustrates the obvious methods to quit. Ctrl-C results in Python whining KeyboardInterrupt but doing nothing helpful. Typing 'exit' or 'quit' both result in messages that make it clear that the interpreter knows what you want to do but won't comply out of spite. More fun can be had with certain versions of Python 3 when running on Windows, where the Python print function would throw an exception if told to print Unicode characters. This made printing to the console non-portable because Unicode characters had to be stripped if running under Windows. This seems to have been fixed, however. Still existing are the misleading warnings that Python produces if you forget to include the self parameter on a class method. Python emits an error that blames code that calls the method for passing one too many parameters instead of identifying the underlying problem. Python also gets similarly unhappy, and points fingers at the wrong code, if the brackets are omitted when instantiating a class. Since Python is dynamically typed, these errors can't be identified until execution. Requiring all-paths testing to catch syntax errors is a special kind of user hostility in and of itself. Python is an utterly horrible language and it's deeply unfortunate that it has become so popular when so many less error-prone, less obnoxious, alternatives exist.
- not2b 6y agoSince 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
- CJefferson 6y agoThat's a terrible message for people trying to run other people's code, unfortunately. It wouod be more useful to say "Are you trying to run Python 2 code in Python 3?", If Python detects enough "2isms" in the file.
- odonnellryan 6y agoExcept that is imprecise and can be misleading. It is certain you called print incorrectly. It is not known if you just made a mistake or are trying to execute python 2 code.
- jbay808 6y agoThis was a while back. In version 3.5 (5 versions after the change was made!) the message was just: SyntaxError: Missing parentheses in call to 'print'. This doesn't give the "did you mean" hint, and while it's perfectly understandable for someone who's gotten as far as learning exceptions in Python, that usually comes a few chapters after "hello world". It's definitely enough to throw a newbie off. And even if they're a veteran of other languages, they might have been exposed to a wide variety of error messages like this that commonly indicate a problem elsewhere, and having never yet successfully run a python script at this point, the prior for an error in configuration is much higher than for the tutorial being wrong.