How do I use '~' (tilde) in the context of paths?

Viewed 71170

I'm a web application development noob. I have a function that opens a file and reads it. Unfortunately, the directory structures between the test and production servers differ. I was told to "use a path relative to ~". I haven't been able to find any resources on the '~', though!

How do I use the tilde character in the context of paths?

EDIT: This is in Python. I fixed the problem, using os.path.expanduser('~/path/in/home/area').

3 Answers

If you are using pathlib for filenames then you can use on both Windows and Linux (I came here for a windows answer):

from pathlib import Path
p = Path('~').expanduser()
print(p)
Related