I have tried to seach online but cound not find the details of sys.path.extend function.
The actual script is below:
``
sys.path.extend([‘C:\\Users\Name\\My Software\\PythonHighstopEval\\used_libraries’])
``
Thanks in advance.
I have tried to seach online but cound not find the details of sys.path.extend function.
The actual script is below:
``
sys.path.extend([‘C:\\Users\Name\\My Software\\PythonHighstopEval\\used_libraries’])
``
Thanks in advance.
\N
— You probably wanted an escaped backslash: \\N
extend
is a method list.extend()
, not a function:
list
is a mutable sequenceextend
is a method of mutable sequencesIn your case you are appending just a single item (single string) so it would be more clear and efficient to use sys.path.append()
instead.
Do you know what sys.path
is?
import
command will search for modules to import.Do you know what the extend
method does for lists?
So sys.path.extend()
takes what should be a list of directories, and adds each of them to the import search path.