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

Walter Szeliga report at bugs.python.org
Thu Feb 2 19:04:13 EST 2017


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 <report at bugs.python.org>
<http://bugs.python.org/issue29425>
_______________________________________


More information about the New-bugs-announce mailing list