I bumped into this statement in a python script : sys.path.append("..")
I did some research, but I could not find what does it do.
I know sys.path.append()
function appends a path at the end of the PYTHONPATH list. But what does ".."
stand for?
Needless to say that this python scripts does not work if I comment the line.
It is generally not good practice to use manipulate sys. path within a python library or program. You should add the relevant paths to the PYTHONPATH in the calling environment for your python program: PYTHONPATH="/path/to/other/projects/directory:$PYTHONPATH" python ...
Appending a value to sys. path only modifies it temporarily, i.e for that session only. Permanent modifications are done by changing PYTHONPATH and the default installation directory.
sys. path. append('/root/mods') Removes all directory for mods.
To undo the sys. path. append , you just need to remove that line from your script. Since the path is only modified for your current script and not system wide until you edit the PYTHONPATH .
".."
is a way of saying/referencing the parent of the current working directory.
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