On 30 November 2016 at 19:05, Paul Moore <p.f.mo...@gmail.com> wrote: > On 30 November 2016 at 02:14, Stephen J. Turnbull > <turnbull.stephen...@u.tsukuba.ac.jp> wrote: >> Wouldn't >> >> NameError: Python doesn't recognize the name "log". Perhaps >> you need to import the "math" module? > > ... and of course up until this example, I'd assumed you were talking > about the log function from the logging module :-) > > I'm a strong +1 on better error messages, but there's always a risk > with heuristics that the resulting messages end up worse, not better. > > Maybe keep it simpler: > > NameError: Python doesn't recognize the name "log". Maybe you > misspelled the name, or did you mean to import the function from a > module? > > and don't try to guess the user's intent.
This brings up a point that I was going to mention earlier: when it comes to specialised learning environments, the folks developing the curriculum also know *what problem the student is working on*, and can tailor their error messages accordingly. The reference interpreter is never going to be able to guess intent like that due to the sheer scope of Python's use cases - by covering everything from students writing "Guess a number" games to mechanical engineers modeling and tuning race car performance to sysadmins automating service deployments to web developers responding to user requests to data analysts trying to make sense of noisy data, we end up being *really* limited in the assumptions we can make about what a user was really trying to do when they accidentally ask for something nonsensical. Tweaking some of the default representations to mention common problems should be OK, though. While some veteran programmers may find such prompts a bit condescending, they'd be better equipped than beginners to opt in to alternative exception display options that omit the hints. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/