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

Hartmut Goebel <[email protected]> Sat, 4 May 2024 19:22:52 +0200
Newsgroups gmane.comp.python.general.german
Organization crazy-compilers.com
Message-ID <[email protected]>
Am 04.05.24 um 13:12 schrieb Marc Haber:
> Wnn ich in d/mc1.py dasselbe tun möchte,
> muss ich dort "from mc2 import MyClass2" schreiben,

Ich vermute, Du musst "from ..mc2 import …" schreiben, da Du das Modul 
relativ zu mc1 "adressieren" musst. Falls es bei Dir ohne ".." ist 
irgendwas faul.

> kann also Code, der
> "verwandte" Module benutzt, nicht frei verschieben.
Ganz verstehe ich Deine Frage nicht, aber ich sag mal: Ja, das ist so 
gedacht. Woher sollte python denn sonst wissen, wo es "MyClass2" findet? 
Und in "keks" muss Du ja auch den "Pfad" zum Modul angeben - warum 
wollte das in einem Modul anders sein?

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          |[email protected]                |
|www.crazy-compilers.com  | compilers which you thought are impossible |
_______________________________________________
python-de Mailingliste -- [email protected]
Zur Abmeldung von dieser Mailingliste senden Sie eine Nachricht an [email protected]
https://mail.python.org/mailman3/lists/python-de.python.org/
Mitgliedsadresse: [email protected]