At 05:10 PM 6/27/2005 +0200, Reinhold Birkenfeld wrote:
>Phillip J. Eby wrote:
> > At 08:20 AM 6/27/2005 +0100, Michael Hoffman wrote:
> >>os.getcwd() returns a string, but path.getcwd() returns a new path
> >>object.
> >
> > In that case, I'd expect it to be 'path.fromcwd()' or 'path.cwd()'; i.e. a
> > constructor classmethod by analogy with 'dict.fromkeys()' or
> > 'datetime.now()'.  'getcwd()' looks like it's getting a property of a path
> > instance, and doesn't match stdlib conventions for constructors.
> >
> > So, +1 as long as it's called cwd() or something better (i.e. clearer
> > and/or more consistent with stdlib constructor conventions).
>
>You're right. +1 for calling it fromcwd().

I'm leaning slightly towards .cwd() for symmetry with datetime.now(), but 
not enough to argue about it if nobody has objections to fromcwd().


>With that settled, should I rewrite the module? Should I write a PEP?

I think the only questions remaining open are where to put it and what to 
call the class.  I think we should put it in os.path, such that 'from 
os.path import path' gives you the path class for your platform, and using 
one of the path modules directly (e.g. 'from posixpath import path') gives 
you the specific platform's version.  This is useful because sometimes you 
need to manipulate paths that are foreign to your current OS.  For example, 
the distutils and other packages sometimes use POSIX paths for input and 
then convert them to local OS paths.  Also, POSIX path objects would be 
useful for creating or parsing the "path" portion of many kinds of URLs, 
and I have often used functions from posixpath for that myself.

As for a PEP, I doubt a PEP is really required for something this simple; I 
have never seen anyone say, "no, we shouldn't have this in the stdlib".  I 
think it would be more important to write reference documentation and a 
complete test suite.

By the way, it also occurs to me that for the sake of subclassability, the 
methods should not return 'path(somestr)' when creating new objects, but 
instead use self.__class__(somestr).

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to