programming:python:packaging
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Last revisionBoth sides next revision | ||
programming:python:packaging [2018-07-25 02:13] – remove __all__ section due to being poor practice zlg | programming:python:packaging [2018-09-22 10:45] – [Single Member Importing] better explain namespacing zlg | ||
---|---|---|---|
Line 52: | Line 52: | ||
</ | </ | ||
- | In the above example, '' | + | In the above example, '' |
+ | |||
+ | If you find yourself | ||
<code python> | <code python> | ||
Line 59: | Line 61: | ||
</ | </ | ||
+ | This is often caused by importing two modules with the same member name. If you import two things with the same member name, the latter name will take precedence: | ||
+ | |||
+ | <code python> | ||
+ | # Same name, different structures | ||
+ | from os import path | ||
+ | print(type(path)) | ||
+ | # <class ' | ||
+ | from sys import path | ||
+ | print(type(path)) | ||
+ | # <class ' | ||
+ | </ | ||
+ | |||
+ | For this reason, it's generally better to leave imports alone and go one level deeper only as needed. So if you wanted to use '' | ||
====== References ====== | ====== References ====== | ||
programming/python/packaging.txt · Last modified: 2023-11-06 20:36 by zlg