I was wondering if there's an idiom for creating dot folders and files for saving config files in all operating systems using Python.
You can get user folder with os.path.expanduser
:
on Win
>>> import os, os.path
>>> os.path.expanduser('~')
'C:\\Documents and Settings\\alko'
on *nix
>>> os.path.expanduser('~')
'/home/alko'
And create dotted folder with os.mkdir
(works on both):
>>> hd = os.path.expanduser('~')
>>> os.mkdir(os.path.join(hd, '.my-config'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With