[Python-Dev] When should pathlib stop being provisional? (original) (raw)
Ethan Furman ethan at stoneleaf.us
Wed Apr 6 16:20:59 EDT 2016
- Previous message (by thread): [Python-Dev] When should pathlib stop being provisional?
- Next message (by thread): [Python-Dev] When should pathlib stop being provisional?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 04/06/2016 02:41 AM, Antoine Pitrou wrote:
On a concrete point, inheriting str would make the API a horrible, confusing, dangerous mess missing regular string semantics (concatenation with +, for example, or indexing) with path-specific semantics and various grey areas (should .split() have path semantics or str semantics? what is the rule and how are people supposed to remember it?).
While I agree in principle..
(of course, for PHP or Javascript programmers it may not sound like a problem. Let "adding" two IP addresses return the concatenation of their string representations...)
Like if had a subnet of '192.168' and a host of '.11.16' and adding them together gave you '192.168.11.16'? (yeah, a bit weak)
Or, more appropriately: a path of
'/home/ethan/mystuff' + '_bak'
so I can make a copy? Actually, that would be
stuff = pathlib.Path('/home/ethan/mystuff') # no issue here backup_stuff = stuff.with_name(stuff.name + '_bak') # eww
Sure, you can make the argument that with_suffix('.bak')
is cleaner,
but it is not up to the stdlib to micromanage my code.
Oh, and I do not consort with PHP, and only do so with Javascript when forced.
--
Ethan
- Previous message (by thread): [Python-Dev] When should pathlib stop being provisional?
- Next message (by thread): [Python-Dev] When should pathlib stop being provisional?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]