[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: equivalent of Ruby's Pathname?

aahz

2/14/2010 8:40:00 PM

In article <8fc356e0-f3ed-4a67-9b37-f21561cef4a5@p13g2000pre.googlegroups.com>,
Sean DiZazzo <half.italian@gmail.com> wrote:
>On Feb 8, 2:36=A0pm, a...@pythoncraft.com (Aahz) wrote:
>> In article <dcace5fc-5ae9-4756-942d-6da7da2f6...@s36g2000prh.googlegroups=
>.com>,
>> Sean DiZazzo =A0<half.ital...@gmail.com> wrote:
>>>
>>>Why did Path() get rejected? Is it the idea itself, or just the
>>>approach that was used? What are the complaints?
>>
>> You should search for the discussiona around it.
>
>I read the discussion, and there was definitely some going back and
>forth on whether it should be sub-classed from string, but the
>conversation just seemed to stop abruptly with no decision one way of
>the other. Maybe I missed a thread.
>
>I guess being dropped without a final go-ahead is just as good as a
>formal no anyway.

Not quite: because it was not rejected, someone who wants to shepherd the
process forward would likely be welcomed (even if it ends up with formal
rejection). I suggest starting by writing your own summary of the
previous discussion and see if the people involved agree that your
summary is reasonably accurate. Also check to see if the original PEP
writer wants to be involved or whether zie is willing to have you take
over.

Another good (and related) starting point would be to create a reasoning
favoring one side or the other that was not brought up in previous
discussion.
--
Aahz (aahz@pythoncraft.com) <*> http://www.python...

"At Resolver we've found it useful to short-circuit any doubt and just
refer to comments in code as 'lies'. :-)"
1 Answer

sluggoster@gmail.com

3/9/2010 11:18:00 PM

0

I just saw this thread on the Python-URL.

On Feb 14, 12:39 pm, a...@pythoncraft.com (Aahz) wrote:
> >> Sean DiZazzo =A0<half.ital...@gmail.com> wrote:
>
> >>>Why did Path() get rejected? Is it the idea itself, or just the
> >>>approach that was used? What are the complaints?
>
> >> You should search for the discussiona around it.
>
> >I read the discussion, and there was definitely some going back and
> >forth on whether it should be sub-classed from string, but the
> >conversation just seemed to stop abruptly with no decision one way of
> >the other.  Maybe I missed a thread.

It has a habit of being discussed and dropped repeatedly. The main
issue is that Guido doesn't see an OO approach as necessarily better
than the existing functions, so it has a high bar for acceptance. One
issue is that some people see a need to separate filesystem-
independent functionality (joining paths and extracting components)
from filesystem-dependent functionality (listing directories, removing
files, etc). ``path.py`` and PEP 355 were rejected mainly because of
this. There was support for a small filesystem-independent class that
could be put into the stdlib, and some modest moving/renaming of the
filesystem functions (which are scattered across os, os.path, shutil,
glob, etc). We were hoping to get this done for Python 3 but didn't
make it. I wrote a ``Unipath`` package that tried to be a compromise
between what everybody wanted, with a FS-independent class and a FS-
dependent subclass, but could not get any feedback on it. Somebody
else was going to write a PEP for the renamings, but I never saw it.

Since then, path.py has been included in a couple packages and seems
to have the most widespread use. I gave up on the stdlib and
reconfigured Unipath as a pure 3rd-party library. (The FS-independent
AbstractPath class is still there if anybody wants to use it for a
PEP.) The other people who made their own implementations seemed to be
happy with theirs, and that was that.

The string vs non-string argument has pretty much been decided in
favor of strings (i.e., a string subclass). Not ``"a.txt".open()`` but
``open(Path("a.txt"))``. Too many standard and 3rd-party modules
expect string paths: you'd have to convert your path to a string every
time you pass it as an argument. The main problem with string paths
is that .join() means something else, but that's usually solved by
using a different method name: "joinpath", "child", "/", etc.

Other proposals have been a tuple subclass, so that ``Path("a/b/c.txt")
[-1] == Path("c.txt")``, and a library that can do non-native paths
(Windows style on Unix systems and vice-versa). These don't seem to be
in vogue anymore.

What has become more common is virtual paths; i.e., the same interface
for filesystems, FTP, zip files, etc. That was discussed during the
last go-around but there were no implementations. Now there are a few
projects active on this, such as http://groups.google.com/gro...
.. This is probably the future of any path object, so it would make
sense to define a path now that can work with all these backends.

--Mike