Skip to content

Instantly share code, notes, and snippets.

@selfboot
Last active April 29, 2019 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save selfboot/39844461e796d6f44c610564f9c6a7a1 to your computer and use it in GitHub Desktop.
Save selfboot/39844461e796d6f44c610564f9c6a7a1 to your computer and use it in GitHub Desktop.
py_scripts.md

You can use os.path.expanduser to convert ~ into your home directory:

>>> import os
>>> os.path.expanduser('~/.config.txt')
'/root/.config.txt'
>>>

This works on both *nix and Windows systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment