Re: [Python-ideas] (no subject)

2016-11-28 Thread Mariatta Wijaya
I'm +1 to the idea of improving error messages :) (but maybe not to the exact new error messages proposed) Raymond Hettinger touched on this topic during his Pycon Canada keynote, as one of the positive contributions that you can do to cpython. > > Traceback (most recent call last): > > File

Re: [Python-ideas] (no subject)

2016-11-28 Thread victor rajewski
Sorry, I forgot the subject line! On Tue., 29 Nov. 2016, 3:58 pm victor rajewski, wrote: > I teach a computing subject to high school students using Python as our > primary language. One thing that often causes confusion at the start is > error messages/exceptions. I think

Re: [Python-ideas] (no subject)

2016-11-28 Thread Bernardo Sulzbach
On 2016-11-29 02:58, victor rajewski wrote: NameError: name 'reponse' is not defined A better message might be: You're trying to use the value of 'reponse', but that variable hasn't got a value yet. You can give it a value earlier in the code, or it could be a typo. You have a variable called

[Python-ideas] (no subject)

2016-11-28 Thread victor rajewski
I teach a computing subject to high school students using Python as our primary language. One thing that often causes confusion at the start is error messages/exceptions. I think it would lower entry point quite a bit by making error messages more readable to novices. Recent research found reduced

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Chris Angelico
On Tue, Nov 29, 2016 at 12:14 PM, Steven D'Aprano wrote: > What if I have two files? > > # a.py > try: > import spam > except ImportError: > import ham as spam > > # b.py > try: > import spam > except ImportError: > import cornedbeef as spam > In the same

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Ethan Furman
On 11/28/2016 05:46 PM, Random832 wrote: On Mon, Nov 28, 2016, at 15:05, Ethan Furman wrote: Because it is unfriendly. Helpful error messages are a great tool to both beginner and seasoned programmers. There won't be a helpful error message unless the distributor writes one. The purpose

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Steven D'Aprano
On Tue, Nov 29, 2016 at 09:52:21AM +1100, Chris Angelico wrote: > +1, because this also provides a coherent way to reword the try/except > import idiom: > > # Current idiom > # somefile.py > try: > import foo > except ImportError: > import subst_foo as foo Nice, clean and

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Steven D'Aprano
On Mon, Nov 28, 2016 at 12:05:01PM -0800, Ethan Furman wrote: > >Honestly, though, I'm not sure of the need for the PEP in general. > >"However, there is as of yet no standardized way of dealing with > >importing a missing standard library module." is simply not true. The > >standardized way of

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Steven D'Aprano
On Mon, Nov 28, 2016 at 02:32:16PM +, Paul Moore wrote: > Also, and possibly more of an issue, use of the ".missing.py" file > will mean that a user can't provide their own implementation of the > module later on sys.path. I don'rt know if this is a significant issue > on Unix platforms. On

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Brett Cannon
On Mon, 28 Nov 2016 at 14:49 Steve Dower wrote: > On 28Nov2016 1433, Steve Dower wrote: > > On 28Nov2016 1419, Nathaniel Smith wrote: > >> I'd suggest that we additional specify that if we find a > >> foo.missing.py, then the code is executed but -- unlike a regular > >>

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Wolfgang Maier
On 28.11.2016 23:52, Chris Angelico wrote: +1, because this also provides a coherent way to reword the try/except import idiom: # Current idiom # somefile.py try: import foo except ImportError: import subst_foo as foo # New idiom: # foo.missing.py import subst_foo as foo import sys;

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Chris Angelico
On Tue, Nov 29, 2016 at 9:19 AM, Nathaniel Smith wrote: > This also suggests that the overall error-handling flow for 'import > foo' should look like: > > 1) run foo.missing.py > 2) if it raises an exception: propagate that > 3) otherwise, if sys.modules["foo"] is missing: raise

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Wolfgang Maier
On 28.11.2016 23:19, Nathaniel Smith wrote: I'd suggest that we additional specify that if we find a foo.missing.py, then the code is executed but -- unlike a regular module load -- it's not automatically inserted into sys.modules["foo"]. That seems like it could only create confusion. And it

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Nathaniel Smith
On Mon, Nov 28, 2016 at 5:28 AM, Tomas Orsava wrote: [...] > Specification > = > > When, for any reason, a standard library module is not to be included with > the > rest, a file with its name and the extension ``.missing.py`` shall be > created > and placed in the

Re: [Python-ideas] Decorator to avoid a mistake

2016-11-28 Thread Chris Barker
On Mon, Nov 28, 2016 at 1:50 PM, Guido van Rossum wrote: > Also -- the ship has kinda sailed on this - maybe a @not_override would >> make more sense. >> >> Isn't the goal to make sure you don't accidentally override a method? >> saying "I know I'm overriding this" is less

Re: [Python-ideas] Decorator to avoid a mistake

2016-11-28 Thread Guido van Rossum
On Mon, Nov 28, 2016 at 1:44 PM, Chris Barker wrote: > > On Mon, Nov 28, 2016 at 1:37 PM, Guido van Rossum > wrote: > > >> They can, and they @override can be bypassed. I don't see that as a >> condemnation of @overload -- it just means that it's not

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Ethan Furman
On 11/28/2016 01:26 PM, Paul Moore wrote: On 28 November 2016 at 21:11, Ethan Furman wrote: One "successful" use-case that would be impacted is the fallback import idiom: try: # this would do two full searches before getting the error import BlahBlah except

Re: [Python-ideas] Decorator to avoid a mistake

2016-11-28 Thread Chris Barker
On Mon, Nov 28, 2016 at 1:37 PM, Guido van Rossum wrote: > They can, and they @override can be bypassed. I don't see that as a > condemnation of @overload -- it just means that it's not perfect, which is > fine with me (given that we're talking about monkey-patching here). >

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Chris Barker
On Mon, Nov 28, 2016 at 1:26 PM, Paul Moore wrote: > > One "successful" use-case that would be impacted is the fallback import > > idiom: > > > > try: > > # this would do two full searches before getting the error > > import BlahBlah > > except ImportError: > >

Re: [Python-ideas] Decorator to avoid a mistake

2016-11-28 Thread Guido van Rossum
On Mon, Nov 28, 2016 at 1:32 PM, Chris Barker wrote: > On Mon, Nov 28, 2016 at 10:22 AM, Guido van Rossum > wrote: > > >> At calling time, the subclass' method will be found, and used, and the >>> search stops there -- no way to know if there is one with

Re: [Python-ideas] Decorator to avoid a mistake

2016-11-28 Thread Chris Barker
On Mon, Nov 28, 2016 at 10:22 AM, Guido van Rossum wrote: > At calling time, the subclass' method will be found, and used, and the >> search stops there -- no way to know if there is one with the same name >> further up the MRO. >> >> This is simply incompatable with a

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Wolfgang Maier
On 28.11.2016 22:26, Paul Moore wrote: On 28 November 2016 at 21:11, Ethan Furman wrote: One "successful" use-case that would be impacted is the fallback import idiom: try: # this would do two full searches before getting the error import BlahBlah except

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Paul Moore
On 28 November 2016 at 21:11, Ethan Furman wrote: > One "successful" use-case that would be impacted is the fallback import > idiom: > > try: > # this would do two full searches before getting the error > import BlahBlah > except ImportError: > import blahblah

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Ethan Furman
On 11/28/2016 01:01 PM, Guido van Rossum wrote: On Mon, Nov 28, 2016 at 12:51 PM, Ethan Furman wrote: On 11/28/2016 05:28 AM, Tomas Orsava wrote: Rendered PEP: https://fedora-python.github.io/pep-drafts/pep-A.html Overall +1, but

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Ethan Furman
On 11/28/2016 05:28 AM, Tomas Orsava wrote: Rendered PEP: https://fedora-python.github.io/pep-drafts/pep-A.html Overall +1, but using Guido's #2 option instead for handling *.missing.py files (searching all possible locations for the module before falling back to the stdlib xxx.missing.py

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Terry Reedy
On 11/28/2016 11:38 AM, Guido van Rossum wrote: Overall I think this is a good idea. I have one hit: It seems that there are two possible strategies for searching the .missing.py file: 1. (Currently in the PEP) search it at the same time as the .py file when walking along sys.path. - Pro:

Re: [Python-ideas] Decorator to avoid a mistake

2016-11-28 Thread Chris Barker
Am I missing something? Given Python's dynamic nature, there is simply no way to know if a method is overriding a superclass' method until it is called -- and, now that I think about it even then you don't know. At compile time, none of the superclasses may have the given method. At run time, a

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Nathaniel Smith
On Nov 28, 2016 8:38 AM, "Guido van Rossum" wrote: > > Overall I think this is a good idea. I have one hit: > > It seems that there are two possible strategies for searching the .missing.py file: > > 1. (Currently in the PEP) search it at the same time as the .py file when

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Alexandre Brault
I would also prefer (2) for exactly the example given in this thread. The Windows version of curses.missing.py could raise a ModuleNotFoundError saying that curses is not available on Windows, but a developer who wants to can install PDCurses to implement the stdlib module. I don't think the few

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Paul Moore
On 28 November 2016 at 15:51, Tomas Orsava wrote: > I believe I may have found the Windows curses implementation, it's called > PDCurses [0], and this website [1] appears to be distributing it under the > name `curses`. My apologies, I should have included a pointer. That is

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Tomas Orsava
On 11/28/2016 03:32 PM, Paul Moore wrote: On 28 November 2016 at 13:28, Tomas Orsava wrote: The ``.missing.py`` extension will be added to the end of the list, and configured to be handled by ``SourceFileLoader``. Thus, if a module is not found in its proper location, the

Re: [Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Paul Moore
On 28 November 2016 at 13:28, Tomas Orsava wrote: > The ``.missing.py`` extension will be added to the end of the list, and > configured to be handled by ``SourceFileLoader``. Thus, if a module is not > found in its proper location, the ``XYZ.missing.py`` file is found and >

[Python-ideas] PEP: Distributing a Subset of the Standard Library

2016-11-28 Thread Tomas Orsava
Hi! We have written a draft PEP entitled "Distributing a Subset of the Standard Library" that aims to standardize and improve how Python handles omissions from its standard library. This is relevant both to Python itself as well as to Linux and other distributions that are packaging it, as