[Python-ideas] PEP 428: poll about the joining syntax

T.B. bauertomer at gmail.com
Tue Oct 9 01:02:05 CEST 2012

On 2012-10-08 23:17, Richard Oudkerk wrote:
> On 08/10/2012 9:22pm, Paul Moore wrote:
>>   p.joinpath(q)
>> +1 I wish there was a better name, but I doubt one will appear :-(
> I would go for
>      p.add(q)
I like the short 'add'. A small problem I see with 'add' (and with 
'append') is that the outcome of adding (or appending) an absolute path 
is too surprising, unlike with the 'join' or 'joinpath' names.

Also, How would we add an extension to a path (without turning it into a 
str first)? Will there be a method called addext() or addsuffix() as the 
.ext/.suffix property is immutable? The suggestions I saw in the thread 
so far targeted substituting the extension, not adding.

Regarding '/', I would like to mention Scapy [1], the packet 
manipulation program. From its documentation: "The / operator has been 
used as a composition operator between two layers". The '/' feels 
natural to use with Scapy. An example from the docs:
> Let’s say I want a broadcast MAC address, and IP payload to ketchup.com and to mayo.com, TTL value from 1 to 9, and an UDP payload:
> >>> Ether(dst="ff:ff:ff:ff:ff:ff")/IP(dst=["ketchup.com","mayo.com"],ttl=(1,9))/UDP()


[1] http://www.secdev.org/projects/scapy/

More information about the Python-ideas mailing list