sys.path.append("../../../") and sys.path.append("..")

115 Views Asked by At

In one program, I noticed that author add two lines

sys.path.append("../../../")
sys.path.append("..")

Is the second path.add redundant?

1

There are 1 best solutions below

0
Arun Kumar Khattri On BEST ANSWER

".." moves you one level up in the directory tree from where you are. So multiple .. moving you further up that many level.

Sys.path is a list of directories where the Python interpreter searches for modules. you may find through print(sys.path). Please note it's a list.

The sys.path.append() method is used to append the path that we want to the existing list.

So second one is not redundant, you are the who added it...