Why is the first element in Python’s sys.path an empty string?

sys.path[0] is an entry created by the Python executable to refer to the directory of the script being run. If no script is being run, e.g. the REPL has been invoked directly, an empty entry representing the current directory is added.

Leave a Comment