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