Re: [Python-ideas] Improve error message when missing 'self' in method definition

2016-10-13 Thread Steven D'Aprano
On Tue, Oct 11, 2016 at 02:31:25PM +1100, Chris Angelico wrote:
> On Tue, Oct 11, 2016 at 2:29 PM, Stephen J. Turnbull
>  wrote:
> > Chris Angelico writes:
> >
> >  > Given that it's not changing semantics at all, just adding info/hints
> >  > to an error message, it could well be added in a point release.
> >
> > But it does change semantics, specifically for doctests.
> 
> Blah, forgot about doctests. Guess that's off the cards for a point
> release, then, but still, shouldn't be a big deal for 3.7.

Error messages are not part of Python's public API. We should be able to 
change error messages at any time, including point releases.

Nevertheless, we shouldn't abuse that right. If it's only a change to 
the error message, and not a functional change, then maybe we can add it 
to the next 3.6 beta or rc. But its probably not worth backporting it to 
older versions.



-- 
Steve
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


Re: [Python-ideas] Improve error message when missing 'self' in method definition

2016-10-10 Thread Stephen J. Turnbull
Chris Angelico writes:

 > Given that it's not changing semantics at all, just adding info/hints
 > to an error message, it could well be added in a point release.

But it does change semantics, specifically for doctests.

I seem to recall that that is considered a blocker for this kind of
change in a maintenance-only branch.  In the end that's probably up to
the RM, but I would be mildly against it.  FWIW YMMV of course.


___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


Re: [Python-ideas] Improve error message when missing 'self' in method definition

2016-10-05 Thread אלעזר
Isn't it possible to implement it as a pure Python exception hook?

On Wed, Oct 5, 2016 at 10:04 PM Ivan Levkivskyi 
wrote:

>
> On 5 October 2016 at 20:55, Yury Selivanov 
> wrote:
>
>
> Speaking of, I'm not much of a C hacker, and messing with CPython internals
> is a little daunting. If anyone wants to take this on, you have my
> blessing. I also may take a shot at implementing this idea in the next
> couple weeks when I have some time.
>
>
> It would help if you could create an issue and write exhaustive unittests
> (or at least specifying how exactly the patch should work for all corner
> cases).  Someone with the knowledge of CPython internals will later add the
> missing C code to the patch.
>
> Yury
>
>
> I agree with Yury here. There are corner cases (like what to do with
> classmethods etc). If behaviour for all of them are specified, it would be
> quite straightforward to implement this.
>
> --
> Ivan
>
> ___
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Improve error message when missing 'self' in method definition

2016-10-05 Thread Ivan Levkivskyi
On 5 October 2016 at 20:55, Yury Selivanov  wrote:

>
> Speaking of, I'm not much of a C hacker, and messing with CPython internals
>> is a little daunting. If anyone wants to take this on, you have my
>> blessing. I also may take a shot at implementing this idea in the next
>> couple weeks when I have some time.
>>
>
> It would help if you could create an issue and write exhaustive unittests
> (or at least specifying how exactly the patch should work for all corner
> cases).  Someone with the knowledge of CPython internals will later add the
> missing C code to the patch.
>
> Yury
>
>
I agree with Yury here. There are corner cases (like what to do with
classmethods etc). If behaviour for all of them are specified, it would be
quite straightforward to implement this.

--
Ivan
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Improve error message when missing 'self' in method definition

2016-10-05 Thread Chris Angelico
On Thu, Oct 6, 2016 at 5:27 AM, Michel Desmoulin
 wrote:
> +1. Python does need better error messages. This and the recent new import
> exception will really help.
>
> Will feature freeze prevent this to get into 3.6 if some champion it?
>

Given that it's not changing semantics at all, just adding info/hints
to an error message, it could well be added in a point release.

+1 on any feature that helps people to debug code. This doesn't look
overly spammy or anything, and it's easy for someone coming from C++
to forget to include that key parameter.

ChrisA
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


Re: [Python-ideas] Improve error message when missing 'self' in method definition

2016-10-05 Thread Stephan Houben
+∞

Another long-time user here who occasionally still makes this mistake.

Stephan

2016-10-05 19:29 GMT+02:00 Paul Moore :

> On 5 October 2016 at 18:17, Lisa Roach  wrote:
> > +1
> >
> > I've definitely seen a lot of new users make this error, an improved
> message
> > could go a long way.
>
> I'm not a new user by any means, and I still regularly make this
> mistake. Because I've got the experience, I recognise the error when I
> see it, but that's not much help for people who haven't already made
> the mistake hundreds of times :-)
>
> +1 on improving the message.
> Paul
> ___
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Improve error message when missing 'self' in method definition

2016-10-05 Thread Paul Moore
On 5 October 2016 at 18:17, Lisa Roach  wrote:
> +1
>
> I've definitely seen a lot of new users make this error, an improved message
> could go a long way.

I'm not a new user by any means, and I still regularly make this
mistake. Because I've got the experience, I recognise the error when I
see it, but that's not much help for people who haven't already made
the mistake hundreds of times :-)

+1 on improving the message.
Paul
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


Re: [Python-ideas] Improve error message when missing 'self' in method definition

2016-10-05 Thread Lisa Roach
+1

I've definitely seen a lot of new users make this error, an improved
message could go a long way.

On Tue, Oct 4, 2016 at 1:52 PM, Nathan Goldbaum 
wrote:

> Hi all,
>
> Recently pypy received a patch that improves the error message one gets
> when 'self' is missing in a method's signature:
>
> https://mail.python.org/pipermail/pypy-dev/2016-September/014678.html
>
> Here are the commits that implement the change in pypy:
>
> https://bitbucket.org/pypy/pypy/commits/all?search=
> branch(better-error-missing-self)
>
> I'm curious whether a similar improvement would also be received well in
> CPython. In particular, this guides one to the correct solution for a
> common programming mistake made by newcomers (and even not-so-newcomers).
>
> Here is a case study that found this was a common source of errors for
> newcomers:
>
> http://dl.acm.org/citation.cfm?id=2960327
>
> -Nathan
>
> ___
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Improve error message when missing 'self' in method definition

2016-10-05 Thread Sylvain Desodt
Hi all,

A bit of shameless self-promotion but in case anyone interested, a while
ago, I had started to work on a project to improve error message. In case
anyone's interested, you can found everything at:
https://github.com/SylvainDe/DidYouMean-Python . It can be invoked in
different ways, one of them being a hook. For instance, you'd get something
like:

>>> import didyoumean_api
>>> didyoumean_api.didyoumean_enablehook()
>>> math.pi
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'math' is not defined*. Did you mean to import math first?*

There is still a lot to be done (and the main thing would be to make it pip
installable) but it may be useful if the improved error messages do not
make it to the CPython interpreter.

Regards

Sylvain
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Improve error message when missing 'self' in method definition

2016-10-04 Thread Yury Selivanov

On 2016-10-04 4:52 PM, Nathan Goldbaum wrote:


Hi all,

Recently pypy received a patch that improves the error message one gets
when 'self' is missing in a method's signature:

https://mail.python.org/pipermail/pypy-dev/2016-September/014678.html

Here are the commits that implement the change in pypy:

https://bitbucket.org/pypy/pypy/commits/all?search=branch(better-error-missing-self)

I'm curious whether a similar improvement would also be received well in
CPython. In particular, this guides one to the correct solution for a
common programming mistake made by newcomers (and even not-so-newcomers).


+1 on the idea.

Yury

___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-ideas] Improve error message when missing 'self' in method definition

2016-10-04 Thread Nathan Goldbaum
Hi all,

Recently pypy received a patch that improves the error message one gets
when 'self' is missing in a method's signature:

https://mail.python.org/pipermail/pypy-dev/2016-September/014678.html

Here are the commits that implement the change in pypy:

https://bitbucket.org/pypy/pypy/commits/all?search=branch(better-error-missing-self)

I'm curious whether a similar improvement would also be received well in
CPython. In particular, this guides one to the correct solution for a
common programming mistake made by newcomers (and even not-so-newcomers).

Here is a case study that found this was a common source of errors for
newcomers:

http://dl.acm.org/citation.cfm?id=2960327

-Nathan
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/