What's the perfect (OS independent) way of storing filepaths ?

Stef Mientki stef.mientki at gmail.com
Sun Oct 19 14:50:46 EDT 2008


Eric Wertman wrote:
>>> I (again) wonder what's the perfect way to store, OS-independent,
>>> filepaths ?
>>>       
>
> I'm in agreement that perfect probably isn't applicable.  If I were
> doing this myself, I might store the information in a tuple:
>
> base = 'some root structure ('/' or 'C')
> path = ['some','set','of','path','names']
> filename = 'somefile.ext'
>
> pathdata = (root,path,filename)
>
> and write a couple of simple functions to reconstruct them based on the os.
>   
Eric, I like your idea.
It looks like a workable technique,
the user should initial define the roots once and everything works.
It should even work for network drives and websites.

Duncan, in windows it's begin to become less common to store settings in 
Docs&Settings,
because these directories are destroyed by roaming profiles (a big 
reason why I can't run Picassa ;-(
It's more common to follow the portable apps approach, store them in the 
application directory.

Drobinow, I want to distribute an application with a large number of 
docs and examples.
Now for this application I can put everything in subpaths of the 
main-application,
but you triggered me to put a warning in my code if I go outside the 
application path.
Another application I've in mind, is a data manager (now written in Delpi),
in which I organize all my information: docs, websites, measurement data 
etc.

Others, thank you for the ideas, you learende me some new os.path functions.

cheers,
Stef

> --
> http://mail.python.org/mailman/listinfo/python-list
>   




More information about the Python-list mailing list