[issue29425] File-altering aspects of pathlib should return new pathlib objects

2017-02-02 Thread Walter Szeliga

New submission from Walter Szeliga:

Methods on pathlib.PosixPath() and other objects that alter files on the file 
system should return new object instances with new information. For example, if 
there exists a file on the system called 'bar', then

bar_var = pathlib.PosixPath('bar')
bar_var.rename('foo')

will rename the file 'bar' to 'foo' on the system and leave 'bar' as a 
still-valid object that no longer points to a system file. Changing the return 
type of .rename() to return a new pathlib.PosixPath() object with path 'foo' 
could help reduce confusion about the behavior. For example:

bar_var = pathlib.PosixPath('bar')
foo_var = bar_var.rename('foo')

and foo_var would then be a pathlib.PosixPath() object pointing to 'foo'.

--
components: Library (Lib)
messages: 286835
nosy: Walter Szeliga
priority: normal
severity: normal
status: open
title: File-altering aspects of pathlib should return new pathlib objects
type: enhancement
versions: Python 3.6

___
Python tracker 
<http://bugs.python.org/issue29425>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29425] File-altering aspects of pathlib should return new pathlib objects

2017-02-07 Thread Walter Szeliga

Walter Szeliga added the comment:

If Path.rename() were made to be slightly more than a wrapper around 
os.rename(), then any future changes to the return value of os.rename() could 
be taken into consideration in the return value of Path.rename(). I don't see 
how anything would become impossible then.

Creating the destination Path object explicitly is my solution right now. Since 
it had become such a pattern in my code, I figured it could be delegated up to 
the level of the Path object and make for cleaner looking code.

--

___
Python tracker 
<http://bugs.python.org/issue29425>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com