Re: [Python-ideas] Define __fspath__() for NamedTemporaryFile and TemporaryDirectory

2017-06-16 Thread Ethan Furman
On 06/16/2017 01:37 PM, Alexandre Brault wrote: So a if used directly, and a if used as a context manager. I don't have a copy of 3.6 nor the future 3.7 handy, so maybe it changed there? The code in master has the context manager return `self.name`. This behaviour has (based on looking at

Re: [Python-ideas] Define __fspath__() for NamedTemporaryFile and TemporaryDirectory

2017-06-16 Thread Thomas Jollans
On 08/06/17 15:42, Antoine Pietri wrote: > Hello everyone! > > A very common pattern when dealing with temporary files is code like this: > > with tempfile.TemporaryDirectory() as tmpdir: > tmp_path = tmpdir.name > > os.chmod(tmp_path) > os.foobar(tmp_path) >

Re: [Python-ideas] Define __fspath__() for NamedTemporaryFile and TemporaryDirectory

2017-06-08 Thread Ethan Furman
On 06/08/2017 12:22 PM, Brett Cannon wrote: Already exists, been discussed, and rejected: https://bugs.python.org/issue29447 . Ah, right, because the returned object is not a file path. Makes sense. -- ~Ethan~ ___ Python-ideas mailing list

Re: [Python-ideas] Define __fspath__() for NamedTemporaryFile and TemporaryDirectory

2017-06-08 Thread Brett Cannon
On Thu, 8 Jun 2017 at 08:27 Ethan Furman wrote: > On 06/08/2017 06:42 AM, Antoine Pietri wrote: > > Hello everyone! > > > > A very common pattern when dealing with temporary files is code like > this: > > > > with tempfile.TemporaryDirectory() as tmpdir: > >

Re: [Python-ideas] Define __fspath__() for NamedTemporaryFile and TemporaryDirectory

2017-06-08 Thread Juancarlo AƱez
On Thu, Jun 8, 2017 at 9:42 AM, Antoine Pietri wrote: > My proposal is to define __fspath__() for TemporaryDirectory and > NamedTemporaryFile so that we can pass those directly to the library > functions instead of having to use the .name attribute explicitely. > +1

Re: [Python-ideas] Define __fspath__() for NamedTemporaryFile and TemporaryDirectory

2017-06-08 Thread Ethan Furman
On 06/08/2017 06:42 AM, Antoine Pietri wrote: Hello everyone! A very common pattern when dealing with temporary files is code like this: with tempfile.TemporaryDirectory() as tmpdir: tmp_path = tmpdir.name os.chmod(tmp_path) os.foobar(tmp_path)

[Python-ideas] Define __fspath__() for NamedTemporaryFile and TemporaryDirectory

2017-06-08 Thread Antoine Pietri
Hello everyone! A very common pattern when dealing with temporary files is code like this: with tempfile.TemporaryDirectory() as tmpdir: tmp_path = tmpdir.name os.chmod(tmp_path) os.foobar(tmp_path) open(tmp_path).read(barquux) PEP 519