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

2018-03-21 Thread Barry Scott
On Tuesday, 20 March 2018 16:22:57 GMT Brett Cannon wrote:
> On Mon, 19 Mar 2018 at 18:08 Chris Barker  wrote:
> > [SNIP]
> > PS: does shutil really still not work with Path objects? aarrgg!
> 
> Did you verify this or are you just guessing? If this is true then file a
> bug and optionally submit a patch. Saying "aarrgg" doesn't fix the
> situation nor motivate people to help out, especially when it sounds like
> you're not even sure yourself that it's even a problem.

Checking this onm 3.6.4 on Fedora it looks like the shutil module
works well with Path().

There was one bit of code that I thought might not work but it is
not a problem as you cannot make a Path('b'filename').

Maybe the simplest change would be to add to the pathlib docs
a notice at the top that says look in shutil and os for the file operations.

Also show some examples of Path() working with shutil to do some
typical operations.

Barry



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


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

2018-03-21 Thread Nick Coghlan
On 20 March 2018 at 16:25, Gregory P. Smith  wrote:

> On Thu, Mar 15, 2018 at 3:26 AM Nick Coghlan  wrote:
>
>> If we did head in this direction, then we'd also need to accept &
>> implement PEP 499 [1] (which proposes aliasing __main__ as
>> __main__.__spec__.name in sys.modules when executed with "-m") to avoid
>> causing problems.
>>
>
> I don't doubt that doing this would require a lot of code cleanup. :)
>

I was recently reminded of a "fun" edge case for PEP 499: "python -m site",
which reruns a module that gets implicitly imported at startup (so "site"
is already in sys.modules by the time __main__ runs).

That said, the way that currently works (re-running sitecustomize and
usercustomize) isn't particularly wonderful, so proposing changing it would
be reasonable.

Cheers,
Nick.

-- 
Nick Coghlan   |   [email protected]   |   Brisbane, Australia
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


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

2018-03-21 Thread Nick Coghlan
On 21 March 2018 at 10:01, Chris Billington 
wrote:

>
>
> On Wed, Mar 21, 2018 at 10:58 AM, Chris Billington <
> [email protected]> wrote:
>
>> I don't think that's true:
>>
>>
>>
>> On Wed, Mar 21, 2018 at 10:51 AM, Greg Ewing > > wrote:
>>
>>> Chris Billington wrote:
>>>
 I wonder how mercurial gets around the fact that its own imports might
 be shadowed by whatever's in the current working directory.

>>>
>>> The cwd is only added to sys.path in the interactive interpreter,
>>> not when you run "python something.py". So it's not usually a
>>> problem for applications implemented in Python.
>>>
>>>
>> I don't think that's true:
>>
>> $ cd /tmp
>> $ echo 'import bar' > foo.py
>> $ echo 'print("this is bar")' > bar.py
>> $ python foo.py
>> this is bar
>>
>> (/tmp is not in the python path)
>>
>>
> Actually I'm mistaken. That's the directory of the script being added to
> the path, not the current working directory.
>

Scripts add the directory of the script, but the "-m" switch adds the
current directory in order to locate modules and packages it can find there
(although it's possible we'll attempt to figure out a way to change that in
the future and require folks to explicitly opt-in to cwd relative main
module imports: https://bugs.python.org/issue33053).

Cheers,
Nick.

-- 
Nick Coghlan   |   [email protected]   |   Brisbane, Australia
___
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/