MCPcopy Index your code
hub / github.com/python/cpython / prepend_syspath

Method prepend_syspath

Lib/idlelib/pyshell.py:697–707  ·  view source on GitHub ↗

Prepend sys.path with file's directory if not already included

(self, filename)

Source from the content-addressed store, hash-verified

695 return filename
696
697 def prepend_syspath(self, filename):
698 "Prepend sys.path with file's directory if not already included"
699 self.runcommand("""if 1:
700 _filename = {!r}
701 import sys as _sys
702 from os.path import dirname as _dirname
703 _dir = _dirname(_filename)
704 if not _dir in _sys.path:
705 _sys.path.insert(0, _dir)
706 del _filename, _sys, _dirname, _dir
707 \n""".format(filename))
708
709 def showsyntaxerror(self, filename=None, **kwargs):
710 """Override Interactive Interpreter method: Use Colorizing

Callers 2

mainFunction · 0.80
run_module_eventMethod · 0.80

Calls 2

runcommandMethod · 0.95
formatMethod · 0.45

Tested by

no test coverage detected