Execute the following commands:
touch sys.py
touch parser.py
python3 -c 'import sys; print(sys)'
pypy3 -c 'import sys; print(sys)'
python3 -c 'import parser; print(parser)'
pypy3 -c 'import parser; print(parser)'
When CPython or PyPy try to import sys, they cannot and it defaults to the builtin module sys.
But some modules are different.
In CPython, if you execute in another folder python3 -c 'import parser; print(parser)'
you'll see the path of the module instead of (built-in)
, and is there is a parser.py
file in the $PYTHONPATH
(sys.path
), it will be imported.
In PyPy3, it seems that parser
has the same status as sys
.
Is there a reference somewhere about those imports? (I know they are bad practice but I wonder why I have not seen this anywhere yet)