[Python-Dev] / as path join operator

Barry Warsaw barry at python.org
Thu Jan 26 05:41:23 CET 2006


On Wed, 2006-01-25 at 21:02 -0600, Ian Bicking wrote:

>    ext = '.jpg'
>    name = fields['name']
>    image = Path('/images') / name + ext

Here's a good example of why I ultimately don't like __div__.  The last
line seems quite non-obvious to me.  It's actually jarring enough that I
have to stop and think about what it means because it /looks/ like
there's math going on.

OTOH, something like:

image = Path('', 'images', name) + ext

or even better

image = Path.join('', 'images', name) + ext

where .join is a staticmethod, seems much clearer.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20060125/4244e51a/attachment.pgp 


More information about the Python-Dev mailing list