path module

holger krekel pyth at devel.trillke.net
Fri Jul 25 12:41:58 EDT 2003


Hello Just,

Just wrote:
>  holger krekel <pyth at devel.trillke.net> wrote:
> > I think it's convenient enough to use "str(path)" if passing a 'path' 
> > instance as a string somewhere.
> 
> If the path object has a __str__ method, apparently it should work 
> without explicit conversion. However, this seems to fail for me on OSX, 
> where an attempt is made to convert to unicode. Providing a __unicode__ 
> method doesn't help. But then again, I think we'd be fine if we add the 
> most used path-taking functions to the path object as methods. I can 
> even see adding some win-specific methods to it.

Yes, i think adding platform specific methods to a Path object makes sense.  
A friend and me started working on (local and subversion) Path 
implementations last week.  Currently a Path instance provides 
these "path-taking" methods 

    open  
    read
    write
    visit  (a recursive walker)
    listdir
    stat
    load/save (unpickle/pickle object)
    setmtime  (set modification time, uses os.utime)

apart from all the os.path.* stuff like 'exists', 'dirname' etc.  
Providing these "path-taking" methods on the Path object is very important 
because otherwise you'll have to convert back and fro for using those
os.* and os.path.* or builtin methods (which is evil).  

cheers,

    holger





More information about the Python-list mailing list