Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Difference Between MicroPython and Python 3 when setting sys.path
- # tested with MicroPython on Linux
- # * built from git master
- # * version = MicroPython v1.11-194-g3d02ebb4e-dirty
- # tested with python3.4 on Linux (Python 3.4.3)
- # * using docker container micktwomey/python3.4
- # * version = Python 3.4.3 (default, Oct 14 2015, 20:28:29)
- ##
- ## TEST1: sys.path from REPL
- ##
- $ ./micropython
- MicroPython v1.11-194-g3d02ebb4e-dirty on 2019-08-11; linux version
- Use Ctrl-D to exit, Ctrl-E for paste mode
- >>> import sys
- >>> print(sys.path)
- ['', '/home/vagrant/.micropython/lib', '/usr/lib/micropython']
- >>>
- $ python3.4 -S
- Python 3.4.3 (default, Oct 14 2015, 20:28:29)
- [GCC 4.8.4] on linux
- >>> import sys
- >>> print(sys.path)
- ['', '/usr/lib/python3.4/', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload']
- >>>
- ##
- ## TEST2: sys.path with code via stdin
- ##
- $ echo "import sys;print(sys.path)" | ./micropython
- ['', '/home/vagrant/.micropython/lib', '/usr/lib/micropython']
- $ echo "import sys;print(sys.path)" | python3.4 -S
- ['', '/usr/lib/python3.4/', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload']
- ##
- ## TEST3: sys.path with code via -c command line argument
- ##
- $ ./micropython -c "import sys;print(sys.path)"
- ['', '/home/vagrant/.micropython/lib', '/usr/lib/micropython']
- $ python3.4 -S -c "import sys;print(sys.path)"
- ['', '/usr/lib/python3.4/', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload']
- ##
- ## TEST4: sys.path with script.py run as command line argument
- ##
- ## script contents:
- ## import sys;print(sys.path)
- ##
- $ pwd
- /py_comparison
- $ ./micropython script.py
- ['/py_comparison', '/home/vagrant/.micropython/lib', '/usr/lib/micropython']
- $ pwd
- /py_comparison
- $ python3.4 -S script.py
- ['/py_comparison', '/usr/lib/python3.4/', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload']
- ##
- ## TEST5: sys.path with script.py run as command line argument, from a different directory
- ##
- ## script contents:
- ## import sys;print(sys.path)
- ##
- $ pwd
- /py_comparison
- $ ./micropython subdir/script.py
- ['/py_comparison/subdir', '/home/vagrant/.micropython/lib', '/usr/lib/micropython']
- $ pwd
- /py_comparison
- $ python3.4 -S subdir/script.py
- ['/py_comparison/subdir', '/usr/lib/python3.4/', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement