Paul Moore wrote:
On 5 October 2012 19:25, Antoine Pitrou
wrote: A path can be joined with another using the ``__getitem__`` operator::
>>> p = PurePosixPath('foo') >>> p['bar'] PurePosixPath('foo/bar') >>> p[PurePosixPath('bar')] PurePosixPath('foo/bar')
There is a risk that this is too "cute". However, it's probably better than overloading the '/' operator, and you do need something short.
I actually like using the '/' operator for this. My own path module uses it, and the resulting code is along the lines of: job = Path('c:/orders/38273') table = dbf.Table(job/'ABC12345')
As with constructing, multiple path components can be specified at once::
>>> p['bar/xyzzy'] PurePosixPath('foo/bar/xyzzy')
That's risky. Are you proposing always using '/' regardless of OS?
Mine does; it also accepts `\\` on Windows machines. Personally, I don't care for the index notation Antoine is suggesting. ~Ethan~