[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: [path-PEP] Path inherits from basestring again
From: Stefan Rank <stefan.rank () ofai ! at>
Date: 2005-07-29 6:45:52
Message-ID: 42E9D0A0.1070704 () ofai ! at
[Download RAW message or body]
[__div__ for .joinpath()]
on 29.07.2005 04:48 Tony Meyer said the following:
>>I, herewith, claim to have used it in the past.
>>But I am indifferent as to if its needed, it just looks natural to me.
>
> So far there seem to have been a few +0s, but no +1s...
>
>>What I use quite often is::
>>
>> path(__file__).dirname() / "somesiblingfileiknowisthere"
>>
>>you do not have to think about trailing slashes or absolute vs.
>>relative. and its much better than::
>>
>> from os.path import *
>> join(dirname(__file__), "somesiblingfileiknowisthere")
>
> In what way is this "much better"?
because of the 'object-orientedness'.
i hope we agree on that (that's the reason for a path PEP?).
the first is only sugar for the explicit::
path(__file__).dirname().joinpath("blablablabalbal")
and as i said +0
operator overloading is only good if it's intuitive for the majority.
(or Guido i suppose, in case this majority-person does not show up)
[snip]
> Would you really choose this:
>
> p = Path() / "build" / "a" / "very" / "very" / "long" / "path"
(Path() is the current dir I think)
>
> Over this:
>
> p = Path(os.path.join("build", "a", "very", "very", "long", "path"))
>
> ? A saving of six characters, and the second one is a lot clearer. If
> there was a os.path.joinPath (or whatever name) function that returned a
> Path object rather than a string, then you'd get:
>
> p = joinPath("build", "a", "very", "very", "long", "path")
>
> Which is better (clearer, more concise) than either of the others, IMO.
actually for explicitness i would choose: (original jorendorff)::
p = path("build").joinpath("any", "path", "you", "can", "imagine")
or otherwise maybe::
p = path("alpha") / "and" / "omega"
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic