SHARE
TWEET

Untitled

a guest Aug 23rd, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## Difference Between MicroPython and Python 3 when setting sys.path
  2.  
  3. # tested with MicroPython on Linux
  4. # * built from git master
  5. # * version = MicroPython v1.11-194-g3d02ebb4e-dirty
  6. # tested with python3.4 on Linux (Python 3.4.3)
  7. # * using docker container micktwomey/python3.4
  8. # * version = Python 3.4.3 (default, Oct 14 2015, 20:28:29)
  9.  
  10. ##
  11. ## TEST1: sys.path from REPL
  12. ##
  13. $ ./micropython
  14. MicroPython v1.11-194-g3d02ebb4e-dirty on 2019-08-11; linux version
  15. Use Ctrl-D to exit, Ctrl-E for paste mode
  16. >>> import sys
  17. >>> print(sys.path)
  18. ['', '/home/vagrant/.micropython/lib', '/usr/lib/micropython']
  19. >>>
  20.  
  21. $ python3.4 -S
  22. Python 3.4.3 (default, Oct 14 2015, 20:28:29)
  23. [GCC 4.8.4] on linux
  24. >>> import sys
  25. >>> print(sys.path)
  26. ['', '/usr/lib/python3.4/', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload']
  27. >>>
  28.  
  29. ##
  30. ## TEST2: sys.path with code via stdin
  31. ##
  32. $ echo "import sys;print(sys.path)" | ./micropython
  33. ['', '/home/vagrant/.micropython/lib', '/usr/lib/micropython']
  34.  
  35. $ echo "import sys;print(sys.path)" | python3.4 -S
  36. ['', '/usr/lib/python3.4/', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload']
  37.  
  38.  
  39. ##
  40. ## TEST3: sys.path with code via -c command line argument
  41. ##
  42. $ ./micropython -c "import sys;print(sys.path)"
  43. ['', '/home/vagrant/.micropython/lib', '/usr/lib/micropython']
  44.  
  45. $ python3.4 -S -c "import sys;print(sys.path)"
  46. ['', '/usr/lib/python3.4/', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload']
  47.  
  48.  
  49. ##
  50. ## TEST4: sys.path with script.py run as command line argument
  51. ##
  52. ## script contents:
  53. ##   import sys;print(sys.path)
  54. ##
  55. $ pwd
  56. /py_comparison
  57. $ ./micropython script.py
  58. ['/py_comparison', '/home/vagrant/.micropython/lib', '/usr/lib/micropython']
  59.  
  60. $ pwd
  61. /py_comparison
  62. $ python3.4 -S script.py
  63. ['/py_comparison', '/usr/lib/python3.4/', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload']
  64.  
  65.  
  66. ##
  67. ## TEST5: sys.path with script.py run as command line argument, from a different directory
  68. ##
  69. ## script contents:
  70. ##   import sys;print(sys.path)
  71. ##
  72. $ pwd
  73. /py_comparison
  74. $ ./micropython subdir/script.py
  75. ['/py_comparison/subdir', '/home/vagrant/.micropython/lib', '/usr/lib/micropython']
  76.  
  77. $ pwd
  78. /py_comparison
  79. $ python3.4 -S subdir/script.py
  80. ['/py_comparison/subdir', '/usr/lib/python3.4/', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload']
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top