Hallo Werner, Frohe Ostern! :) On Sun, 2004-04-11 12:17:00 +0200, Werner Warweg wrote:
Trotz 5 Büchern, die ich mir gekauft habe, finde ich keine Antwort auf die Frage, wie und in welcher Reihenfolge Python seine Module, Dateien etc. zusammensucht.
"Module" ist mir relativ klar, aber was meinst du zum Beispiel mit "Dateien etc."?
Magic-Lines fand ich nur unter Linux im Buch Python 2.x, Das
Was heißt "Magic-Lines"? Meinst du "#! /pfad/zum/interpreter" in der ersten Zeile?
Einsteigerseminar von Martin Uzak. Da steht aber auch ausdrücklich, "das funktioniert nur unter Unix".
Wie kann man zwei Versionen des Interpreters auf dem System haben, da ja sicherlich nicht alle Komponenten immer auch sofort für ein neues Release zur Verfügung steht.
Die reinen Python-Module laufen normalerweise auch auf jeder neueren Version. Viele kompilierte Erweiterungen werden auch schon während der Beta-Phase einer neuen Python-Version getestet und in kompilierter Form angeboten. Davon abgesehen, kannst du mehrere Python-Versionen auf dem Rechner haben, sofern du sie in unterschiedlichen Verzeichnissen bzw. Verzeichnis-Bäumen installierst. Jedenfalls ist das kein Problem, wenn man Python selbst kompiliert und dabei auch den zukünftigen Pfad angibt. In einem laufenden Python-Prozess werden zum Finden der Module die Verzeichnisse in sys.path abgesucht. Standardmäßig sind darin die Pfade enthalten, die die Standard-Bibliothek enthalten, die zum laufenden Binary gehört. Zum Beispiel: Python 2.3.3 (#2, Mar 27 2004, 23:18:46) [GCC 3.3.3 [FreeBSD] 20031106] on freebsd5 Type "help", "copyright", "credits" or "license" for more information.
import sys sys.path ['', '/usr/local/lib/python23.zip', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-freebsd5', '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload', '/usr/local/lib/python2.3/site-packages', '/usr/local/lib/python2.3/site-packages/Numeric', '/usr/local/lib/python2.3/site-packages/PIL', '/usr/local/lib/python2.3/site-packages/piddle']
Der String '' am Anfang bezeichnet das aktuelle Verzeichnis. Frage an die anderen: Wie finden die Verzeichnisse zu den nachträglichen Erweiterungen (PIL etc.) ihren Weg in sys.path? Werden einfach alle Verzeichnisse in site-packages mit aufgenommen? Du kannst sys.path in-place verändern, um die Suchreihenfolge für _danach_ importierte Module zu verändern. Falls du ein Python-Binary hast, aber andere Pfade durchsuchen willst, kannst du zusätzliche Suchpfade über die Umgebungsvariable PYTHONPATH angeben. Schau mal in die Online-Doku auf http://www.python.org .
Um nicht alle Projekte wieder überarbeiten zu müssen, bietet es sich an, auch frühere Stände zu speichern.
Was meinst du mit "frühere Stände"? Viele Grüße Stefan _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de