Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.python > #6061

Re: [Python-de] Re: Pfade, Modulnamen und import-Statements

From "Peter J. Holzer" <hjp-usenet4@hjp.at>
Newsgroups de.comp.lang.python
Subject Re: [Python-de] Re: Pfade, Modulnamen und import-Statements
Date 2024-05-10 19:25 +0200
Organization LUGA
Message-ID <slrnv3sm4l.1tos.hjp-usenet4@trintignant.hjp.at> (permalink)
References <ZjYYBgoIiqLkxkB3@torres.zugschlus.de> <slrnv3dkgq.14mcq.hjp-usenet4@trintignant.hjp.at> <ZjdCdg94EQs3zPul@torres.zugschlus.de> <slrnv3eocq.16cpt.hjp-usenet4@trintignant.hjp.at> <Zj3rZAstdShbMuSt@torres.zugschlus.de>

Show all headers | View raw


On 2024-05-10 09:39, Marc Haber <mh+python-de@zugschlus.de> wrote:
> On Sun, May 05, 2024 at 12:38:18PM +0200, Peter J. Holzer wrote:
>> Ah, dachte ich mir, dass da eine wichtige Information fehlt ;-).
>
> Welche?

Die Information, dass Du das gleiche Python-File einmal mittels import
und einmal als Script ausführst.

Das sind unterschiedliche Mechanismen.

> Dass ich den Empfehlungen des Python Tutorials, Kapitel 6.1.1
> "Executing modules as scripts" gefolgt bin? War das falsch?

Das funktioniert in einigen einfachen Fällen (insbesondere, wenn das
Modul keine weiteren Imports (außer Standard-Modulen) hat oder wenn die
alle direkt im Suchpfad liegen. Wenn man das mit einem Submodul eines
Packages probiert, muss man sich das Environment entsprechend herrichten
(z.B. indem man $PYTHONPATH passend setzt). Keine große Hexerei, wenn
man es weiß, aber selbst dann vergisst man gerne darauf (ich zumindest).
Ich würde daher davon abraten.

        hp

Back to de.comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

[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