Re: [Python-ideas] New PEP proposal -- Pathlib Module Should Contain All File Operations

2018-03-13 Thread Steven D'Aprano
On Mon, Mar 12, 2018 at 09:57:32PM +0100, George Fischhof wrote: > Right now we have several modules that contain functions related > to file-system operations mainly the os, pathlib and shutil. > For beginners it is quite hard to remember where can he / she find > a function (copy resides in shut

Re: [Python-ideas] New PEP proposal -- Pathlib Module Should Contain All File Operations

2018-03-13 Thread Rhodri James
On 12/03/18 20:57, George Fischhof wrote: Good day all, as it seemed to be a good idea, I wrote a PEP proposal for pathlib to contain file operations. Here is the draft. What do you think about this? I am mildly negative about this. In my copious spare time (ho ho) I have been considering t

[Python-ideas] Pythonic access protection

2018-03-13 Thread Neil Girdhar
Now that Python has type annotations has there been any thought into having access protection annotations. This would be for same reason as type annotations: to give the linter the opportunity to catch bugs early, and to give the programmer a uniform way to specify invariants. Unlike type anno

[Python-ideas] Disallow importing the same module under multiple names

2018-03-13 Thread Chris Billington
The Python "double import" problem (discussed here ) leads to subtle bugs in code that change depending on what directory the code was run from. It's hard to think of reasons why importing the same filepath mult

Re: [Python-ideas] Disallow importing the same module under multiple names

2018-03-13 Thread Steven D'Aprano
On Wed, Mar 14, 2018 at 04:20:20PM +1100, Chris Billington wrote: > Instead, maybe a user should just get a big fat error if they try to import > the same file twice under different names. Absolutely not. Suppose I import a library, Spam, which does "import numpy". Now I try to "import numpy as

Re: [Python-ideas] Disallow importing the same module under multiple names

2018-03-13 Thread Chris Angelico
On Wed, Mar 14, 2018 at 4:58 PM, Steven D'Aprano wrote: > On Wed, Mar 14, 2018 at 04:20:20PM +1100, Chris Billington wrote: > >> Instead, maybe a user should just get a big fat error if they try to import >> the same file twice under different names. > > Absolutely not. > > Suppose I import a libr

Re: [Python-ideas] Disallow importing the same module under multiple names

2018-03-13 Thread Chris Billington
Exactly. The example in the "if __name__ == '__main__'" block of my module I linked imports numpy as np, and then adds the numpy package directory to sys.path and imports linalg. This is detected as numpy.linalg being imported twice, once as numpy.linalg, and once as linalg. The output error is be