Can Python directory names be keywords? For instance. 'Import'?

Am I allowed to have a directory named "import" containing Python code? Or will the import team not be able to analyze it as a result? Is there any way around this?

+3
source share
3 answers

You can use the built-in function __import__that accepts any string. So you can write:

__import__('keyword.submodule')
+9
source

, Python Python. , Python.

+4

Or will the import team not be able to analyze it as a result?

It really won't work.

0
source

Source: https://habr.com/ru/post/1740977/


All Articles