programming:python:packaging
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
programming:python:packaging [2018-07-25 02:13] – remove __all__ section due to being poor practice zlg | programming:python:packaging [2023-11-06 20:36] (current) – add notice about Python community's kerfuffle about packaging zlg | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Packaging ====== | ====== Packaging ====== | ||
+ | |||
+ | FIXME :!: The Python community has some PEPs and a lot of debate over what the ' | ||
In Python, individual source files are referred to as **modules**. They represent a single collection of code, and can be '' | In Python, individual source files are referred to as **modules**. They represent a single collection of code, and can be '' | ||
Line 52: | Line 54: | ||
</ | </ | ||
- | In the above example, '' | + | In the above example, '' |
+ | |||
+ | If you find yourself | ||
<code python> | <code python> | ||
Line 59: | Line 63: | ||
</ | </ | ||
+ | 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.1532484800.txt.gz · Last modified: 2018-07-25 02:13 by zlg