Forum Archive

Pythonista Root Dir - 'Documents' is static or language dependent ?

Phuket2

Firstly I assume to get the root or home dir for Pythonista you do:
os.path.expanduser('~') + '/Documents/'

I think that's correct anyway.

my question is, is 'Documents' static across all languages and including double byte such as Japanese etc?

@omz should we allow in our scripts that this could change in the future? maybe there is a better way to get the root/home dir rather than appending 'Documents' to expanduser.

Edit: I should have asked the same questions about the site-packages dir

Phuket2

@omz, Ok, after all that crap.i am guessing the exact right way should be via another Pythonista specific module environment/paths or something like that. So anything you may change in the future is easily handled inside your module. Well, it's the conclusion I have come too after a few more whiskeys anyway. As well as double byte system issues etc

omz

The internal directory structure is not locale-/language-dependent. It'll always be Documents, though that's a (conventional) name I chose, and it could theoretically be something else.

I'd recommend to use expanduser() with the full path instead of adding '/Documents/' afterwards:

os.path.expanduser('~/Documents/')

In general, if you want to concatenate two paths, it's usually better to use os.path.join() instead of +.

Phuket2

@omz , sorry we just missed each on our posts 😬

Phuket2

@omz , just when you thought I couldn't be anymore annoying 😁
Sorry one thing more to mention.
I think it would be nice if in the site-packages directory, you had another directory called something like 'App Files' or 'Config' or something like that. And then by convention apps that are saving config info , create a directory inside your special folder and store their app specific config info inside their folder.

Just as a convention, they don't have to of course