Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #6059
| From | Marc Haber <mh+python-de@zugschlus.de> |
|---|---|
| Newsgroups | de.comp.lang.python |
| Subject | [Python-de] Re: Pfade, Modulnamen und import-Statements |
| Date | 2024-05-10 11:37 +0200 |
| Message-ID | <Zj3q0Y19HfBbszdv@torres.zugschlus.de> (permalink) |
| References | <ZjYYBgoIiqLkxkB3@torres.zugschlus.de> <a1b0c3e8-9e07-4cde-9b19-2bc800d51db0@crazy-compilers.com> <ZjdBpXoZUmsZAWaG@torres.zugschlus.de> <slrnv3eo1s.mt.usenet@mobilewave.waldi.eu.org> |
On Sun, May 05, 2024 at 10:32:28AM -0000, Bastian Blank wrote: > Marc Haber wrote: > > [37/5247]mh@swivel:~/git/zg2dns $ grep -E 'class|import' get-root zg2dns/* > > get-root:from zg2dns.rootdata import DNSRootDataParser > > zg2dns/query.py:from rootdata import DNSRootDataParser > > zg2dns/query.py:class Zg2DNSQuery: > > zg2dns/rootdata.py:class DNSRootDataParser: > > Versuche mal "zg2dns.query" zu importieren Wo? > Der Python-Interpreter fügt das Verzeichnis, in dem das aktuelle Script > liegt, dem Suchpfad hinzu. > > Rufst du "get-root" auf, dann ist es ".". Damit findet "import > zg2dns.rootdata" auch "zg2dns/rootdata.py". > > Rufst du aber "zg2dns/query.py" direkt auf, dann ist auf einmal > das Verzeichnis "zg2dns" im Suchpfad. Also referenziert "import > rootdata" auf einmal was anderes. Also muss ich abhängig von dem Ort wo mein Skript liegt unterschiedliche import-Statements benutzen, das finde ich mindestens unschön. Aber jetzt wo ich es weiß kann ich aes natürlich machen. > Dafür gibt es "pip install -e ." z.B. Damit macht man das aktuelle > Projekt im globalen Suchpfad des benutzten Interpreters verfügbar. Aber hoffentlich nur im Environment einer Subshell? Oder ist das persistentes Herumfummeln im System? Wenn ja, wo? > > Wir arbeiten Modulentwicker in so einer Situation? > > Module werden nicht als Scripte direkt aufgerufen, sind also auch nie > ausführbar. Statt dessen werden sie mittels "python3 -m" aufgerufen. Das Python Tutorial Kapitel 6.1.1 "Executing modules as scripts" stelt das als ganz praktisches Feature dar. Grüße Marc -- ----------------------------------------------------------------------------- Marc Haber | "I don't trust Computers. They | Mailadresse im Header Leimen, Germany | lose things." Winona Ryder | Fon: *49 6224 1600402 Nordisch by Nature | How to make an American Quilt | Fax: *49 6224 1600421
Back to de.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
[Python-de] Pfade, Modulnamen und import-Statements Marc Haber <mh+python-de@zugschlus.de> - 2024-05-04 13:12 +0200
[Python-de] Re: Pfade, Modulnamen und import-Statements Hartmut Goebel <h.goebel@crazy-compilers.com> - 2024-05-04 19:22 +0200
[Python-de] Re: Pfade, Modulnamen und import-Statements Marc Haber <mh+python-de@zugschlus.de> - 2024-05-05 10:21 +0200
Re: [Python-de] Re: Pfade, Modulnamen und import-Statements Bastian Blank <usenet@waldi.eu.org> - 2024-05-05 10:32 +0000
[Python-de] Re: Pfade, Modulnamen und import-Statements Marc Haber <mh+python-de@zugschlus.de> - 2024-05-10 11:37 +0200
[Python-de] Re: Pfade, Modulnamen und import-Statements Hartmut Goebel <h.goebel@crazy-compilers.com> - 2024-05-11 17:49 +0200
Re: [Python-de] Pfade, Modulnamen und import-Statements "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2024-05-05 02:26 +0200
[Python-de] Re: Pfade, Modulnamen und import-Statements Marc Haber <mh+python-de@zugschlus.de> - 2024-05-05 10:25 +0200
Re: [Python-de] Re: Pfade, Modulnamen und import-Statements "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2024-05-05 12:38 +0200
[Python-de] Re: Pfade, Modulnamen und import-Statements Marc Haber <mh+python-de@zugschlus.de> - 2024-05-10 11:39 +0200
Re: [Python-de] Re: Pfade, Modulnamen und import-Statements "Peter J. Holzer" <hjp-usenet4@hjp.at> - 2024-05-10 19:25 +0200
Re: [Python-de] Pfade, Modulnamen und import-Statements Hermann Riemann <nospam.ng@hermann-riemann.de> - 2024-05-05 12:02 +0200
[Python-de] Re: Pfade, Modulnamen und import-Statements Marc Haber <mh+python-de@zugschlus.de> - 2024-05-05 12:35 +0200
Re: [Python-de] Pfade, Modulnamen und import-Statements Hermann Riemann <nospam.ng@hermann-riemann.de> - 2024-05-10 20:05 +0200
[Python-de] Re: Pfade, Modulnamen und import-Statements Christopher Arndt <chris@chrisarndt.de> - 2024-05-11 15:18 +0200
[Python-de] Re: Pfade, Modulnamen und import-Statements Hartmut Goebel <h.goebel@goebel-consult.de> - 2025-01-26 21:21 +0100
csiph-web