Re: [Python-ideas] Relative Imports

2018-11-13 Thread Chris Angelico
On Wed, Nov 14, 2018 at 5:15 PM Steven D'Aprano wrote: > Beware of "obvious" solutions, because so often they lead to not so > obvious problems. Like Javascript's "relative import hell": > > Quote: > > // what we want > import reducer from 'reducer'; > // what we don't want >

Re: [Python-ideas] Relative Imports

2018-11-13 Thread Steven D'Aprano
On Tue, Nov 13, 2018 at 09:34:33PM -0800, Yuval Greenfield wrote: > I would like to propose allowing importing of strings that would support > relative paths. For example in Danish's example: > > # use this in `test_main.py` > import '../main.py' as main How does that differ from

Re: [Python-ideas] Relative Imports

2018-11-13 Thread Yuval Greenfield
On Tue, Nov 13, 2018 at 4:46 PM Chris Barker - NOAA Federal via Python-ideas wrote: > Then I discovered setuptools’ develop mode (now pip editable install) > > It is the right way to run code in packages under development. > In multiple workplaces I found a folder with python utility scripts

Re: [Python-ideas] Relative Imports

2018-11-13 Thread Nathaniel Smith
On Fri, Nov 9, 2018 at 4:32 PM, danish bluecheese wrote: > you are right on the lines you mentioned. Those are all working if i run it > as a module which i do every time. > This is somewhat unpleasant to me, especially while developing something and > trying to test it quickly. > I just want to

Re: [Python-ideas] Relative Imports

2018-11-13 Thread Chris Barker - NOAA Federal via Python-ideas
This is somewhat unpleasant to me, especially while developing something and trying to test it quickly. I just want to be able to use same relative imports and run single file with `python3 test_main.py` for example. I had the same frustration when I first tried to use relative imports. Then I

Re: [Python-ideas] Range and slice syntax

2018-11-13 Thread Chris Angelico
On Wed, Nov 14, 2018 at 5:14 AM David Allemang wrote: > > That is not what slice.indices does. Per help(slice.indices) - > > "S.indices(len) -> (start, stop, stride) > > "Assuming a sequence of length len, calculate the start and stop indices, and > the stride length of the extended slice

Re: [Python-ideas] Range and slice syntax

2018-11-13 Thread David Allemang
That is not what slice.indices does. Per help(slice.indices) - "S.indices(len) -> (start, stop, stride) "Assuming a sequence of length len, calculate the start and stop indices, and the stride length of the extended slice described by S. Out of bounds indices are clipped in a manner consistent

Re: [Python-ideas] Range and slice syntax

2018-11-13 Thread Vladimir Filipović
On Mon, Nov 12, 2018 at 4:43 PM Nicholas Harrison wrote: > Only when this is called (implicitly or explicitly) do checks for valid > objects and bounds occur. From my experience using slices, this is how they > work in that context too. On reconsideration, I've found one more argument in