1

According to https://docs.python.org/2/library/sys.html#sys.path the first item in sys.path should be the directory of the script that was originally called by the interpreter.

I created a simple script that prints out the information contained in sys.path and sys.argv and got the following (note only difference between the two scripts that are run is /Python one has () for print and the /IronPython one does not:

System Info: 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] Copyright (c) 2001-2015 Python Software Foundation.
All Rights Reserved.

Copyright (c) 2000 BeOpen.com.
All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.

Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved.

Hello world!

Sys.Path:
 - c:\Users\220040509\workspace\ApplianceTools\Source\Scripts\Python
 - C:\Windows\system32\python34.zip
 - C:\Python34\DLLs
 - C:\Python34\lib
 - C:\Python34
 - C:\Python34\lib\site-packages

Sys.Argv:
 - <class 'str'> : Python/sysTest.py

System Info: 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] Copyright (c) 2001-2013 Python Software Foundation.
All Rights Reserved.

Copyright (c) 2000 BeOpen.com.
All Rights Reserved.

Copyright (c) 1995-2001 Corporation for National Research Initiatives.
All Rights Reserved.

Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
All Rights Reserved.

Hello world!

Sys.Path:
 - c:\Users\220040509\workspace\ApplianceTools\Source\Scripts\IronPython
 - C:\Windows\system32\python27.zip
 - c:\Python27\DLLs
 - c:\Python27\lib
 - c:\Python27\lib\plat-win
 - c:\Python27\lib\lib-tk
 - c:\Python27
 - c:\Python27\lib\site-packages

Sys.Argv:
 - <type 'str'> : IronPython/sysTest.py

System Info: 2.7.5 (IronPython 2.7.5 (2.7.5.0) on .NET 4.0.30319.18063 (32-bit)) Copyright (c) IronPython Team

Hello world!

Sys.Path:
 - IronPython/sysTest.py
 - c:\Users\220040509\workspace\ApplianceTools\Source\Scripts\IronPython
 - c:\Program Files (x86)\IronPython 2.7\Lib
 - c:\Program Files (x86)\IronPython 2.7\DLLs
 - c:\Program Files (x86)\IronPython 2.7
 - c:\Program Files (x86)\IronPython 2.7\lib\site-packages

Sys.Argv:
 - <type 'str'> : IronPython/sysTest.py

Why does IronPython have the script file (which is also sys.argv[0]) as sys.path[0]?

(ran this in Git Bash, hence the mix of \ and /)

Waters
  • 343
  • 1
  • 11

0 Answers0