Hallo zusammen,
mal eine prinzipielle Frage: Ich realisiere ein Projekt, in welchem viele Pakete genutzt werden. Immer wieder benötigter Code ist aber in einer Base.py untergebracht.
Also folgende Situation:
./
+ program.py
+ base.py
- Paket A/
- modulA1.py
- modulA2.py
- Paket B/
- modulB1.py
- modulB2.py
Wie kann man jetzt von modulB1 Prozeduren von base benutzen?
code organisieren
Es gibt relative importe: http://docs.python.org/whatsnew/2.5.htm ... ve-imports
[url=http://wiki.python-forum.de/PEP%208%20%28%C3%9Cbersetzung%29]PEP 8[/url] - Quak!
[url=http://tutorial.pocoo.org/index.html]Tutorial in Deutsch[/url]
[url=http://tutorial.pocoo.org/index.html]Tutorial in Deutsch[/url]
Vielen Dank, nur zum Verständnis:
toplevel Paket - also so oder:
Und wie greift man dann drauf zu nur mittels
import base ???
toplevel Paket - also so oder:
Code: Alles auswählen
./toplevel
+ __init__.py
+ base.py
+ program.py
-./PaketA
+ modulA1.py
+ modulA2.py
-./PaketB
+ modulB1.py
+ modulB2.py
import base ???
CU sedi
----------------------------------------------------------
Python 3.5; Python 3.6
LinuxMint18
----------------------------------------------------------
Python 3.5; Python 3.6
LinuxMint18