Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8335
| Subject | Re: doing cross platform file work |
|---|---|
| From | Ryan Kelly <ryan@rfk.id.au> |
| References | <201106221044.57169.tjhanson@yahoo.com> |
| Date | 2011-06-24 08:54 +1000 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.344.1308869703.1164.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
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@rfk.id.au | http://www.rfk.id.au/ramblings/gpg/ for details
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: doing cross platform file work Ryan Kelly <ryan@rfk.id.au> - 2011-06-24 08:54 +1000
csiph-web