doing cross platform file work

Ryan Kelly ryan at rfk.id.au
Thu Jun 23 18:54:45 EDT 2011


On Wed, 2011-06-22 at 10:44 -0700, Tim Hanson wrote:
> Thanks for your responses to my student question about using OS paths in 
> Python.
> 
> For the more general case, I am a Linux user interested in making my scripts 
> platform neutral, which would include Linux, Unix (including Mac), and 
> Windows.  I have looked at the python.org os segment and didn't get an answer.
> 
> Is there a library (bonus would be some tutorial material) for making sure my 
> Linux scripts access files and directories on the other platforms 
> transparently?  I don't need the information immediately, but at some point...

You could go all out and use the PyFilesystem module:

   http://packages.python.org/fs/


This provides a unified API not only for accessing files on your local
disk in a platform-agnostic manner, but also for accessing files in a
zip archive, on a remote server, in memory, and from a variety of other
sources.

Even if you only ever intend to access local files, I find the API
provided by PyFilesystem much nicer than using the various modules from
the stdlib.


  Cheers,

     Ryan


-- 
Ryan Kelly
http://www.rfk.id.au  |  This message is digitally signed. Please visit
ryan at rfk.id.au        |  http://www.rfk.id.au/ramblings/gpg/ for details

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20110624/004bb28d/attachment-0001.sig>


More information about the Python-list mailing list