Don't make test.py in Python!

Some people may have wondered, "Why?", But the standard Python library is test. Since there is a package called, an error will occur if test.py or the module imported by test.py uses this package. It's best not to create a script named test.py.

The log below is what I actually tried.

$ echo from test import support >test.py
$ python test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from test import support
  File "/tmp/tmp.TWTFmPjXqY/test.py", line 1, in <module>
    from test import support
ImportError: cannot import name support
$ mv test.py test_.py
$ python test_.py
$ 

When I run from test import support in test.py, I get an ImportError, but I can see that if I rename it to test_.py and then run it, no error occurs.

As mentioned above, I was careful because I was caught before, but I accidentally forgot and got caught again, so I wrote the tips with my own caution.

Recommended Posts

Don't make test.py in Python!
Make a bookmarklet in Python
Make Opencv available in Python
Make python segfault in 2 lines
Make standard output non-blocking in Python
Make python segfault in three lines
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
Make ASCII art GIF animation in Python
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Don't use \ d in Python 3 regular expressions!
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
Let's make a combination calculation in Python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Make cron-like jobs run regularly in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
Make a copy of the list in Python
Make a rock-paper-scissors game in one line (python)
Let's make some notification processing samples in Python
Don't use readlines () in your Python for statement!
Make a joyplot-like plot of R in python
How to make Python Interpreter changes in Pycharm
Daily AtCoder # 36 in Python
Clustering text in Python
Implement Enigma in python
Daily AtCoder # 32 in Python