Dev] / as path join operator (was: Re: The path module PEP) (original) (raw)

Steven Bethard steven.bethard at gmail.com
Thu Jan 26 01:45:20 CET 2006


John J Lee wrote:

On Thu, 26 Jan 2006, Tony Meyer wrote: [...] > Well, if you include the much larger discussion on python-list, > people (including me) have said that removing div is a good > idea. If it's included in the PEP, please at least include a > justification and cover the problems with it. The vast majority of > people (at least at the time) were either +0 or -0, not +1. +0's are > not justification for including something.

FWLIW, I'm definitely +1 on using / as a path join operator.

My only fear with the / operator is that we'll end up with the same problems we have for using % in string formatting -- the order of operations might not be what users expect. Since join is conceptually an addition-like operator, I would expect:

Path('home') / 'a' * 5

to give me:

home/aaaaa

If I understand it right, it would actually give me something like:

home/ahome/ahome/ahome/ahome/a

I don't want to claim this is the most common use case, but I've certainly seen auto-generated paths that look like 'a' * 20, and it would be a pity if using the / operator for Path objects did the wrong thing by default here...

STeVe

You can wordify anything if you just verb it. --- Bucky Katt, Get Fuzzy



More information about the Python-Dev mailing list