In Python, sys.path.append('path/to/module') throws syntax error -
i trying append module path pythonpath environment variable
import sys sys.path.append(0,"/path/to/module/abc.py")
i getting syntax error
syntax error: word unexpected (expecting ")")
can me correct syntax sys.path.append()
?
both answers correct.
append()
default adds argument end of list. it's throwing syntax error passing 2 arguments , accepting 1.
judging syntax want path added front of path insert()
method use.
you can read more in documentation on data structures
list.append(x)
add item end of list; equivalent a[len(a):] = [x].
list.insert(i, x)
insert item @ given position. first argument index of element before insert,
a.insert(0, x)
inserts @ front of list, ,a.insert(len(a), x)
equivalenta.append(x)
.
import sys # inserts @ front of path sys.path.insert(0, "/path/to/module/abc.py") # inserts @ end of path sys.path.append('/path/to/module/abc.py')
Comments
Post a Comment