Am 26.01.25 um 20:55 schrieb Stefan Ram:
Nun, "module.py" als Skript starten, und es gibt eine Fehlermeldung!
Warum? Weil Python das Verzeichnis "package" nicht als Package sieht.
Nicht ganz.
Neuere Versionen von Python (3.10, evtl. schon früher) betrachten ein
Verzeichnis auch ohne __init__.py als Package.
Aber "python package/module.py" startet die Datei eben - wie Du
schreibst - als Skript. Und Skript können keine relativen Importe
enthalten. Eben weil sie Skripte und keine Module eines Packages sind.
Du könntest allerdings das Module "package.module" ausführen, das geht:
python -m package.module
--
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP, ISO 27001 Lead Implementer
Information Security Management, Security Governance, Secure Software
Development
Goebel Consult, Landshut
http://www.goebel-consult.de
Blog: https://www.goebel-consult.de/blog/2019/blockchain-bringts-nicht/
Kolumne:
https://www.goebel-consult.de/blog/cissp-gefluester/2011-10-aus-der-schublade-in-die-koepfe/
_______________________________________________
python-de Mailingliste -- python-de@python.org
Zur Abmeldung von dieser Mailingliste senden Sie eine Nachricht an
python-de-le...@python.org
https://mail.python.org/mailman3/lists/python-de.python.org/
Mitgliedsadresse: arch...@mail-archive.com