python-devel-tools

wrobell wrobell w pld-linux.org
Nie, 2 Maj 2004, 18:22:05 CEST


On Sun, May 02, 2004 at 04:58:58PM +0200, Jacek Konieczny wrote:
> On Sun, May 02, 2004 at 12:59:09PM +0200, wrobell wrote:
> > bedzie wiedzial - nie ma ustawionego PYTHONPATH, co jest udokumentowane
> > w przeciwnosci do tego pseudo-feature obecnego.
> 
> Zaglądałeś do dokumentacji Pythona?
tak, via pydoc site, nie do tutoriala :-P

> 6.1.1 The Module Search Path
> 
>    When a module named spam is imported, the interpreter searches for a file named spam.py in the
>    current directory, and then in the list of directories specified by the environment variable
>    PYTHONPATH. This has the same syntax as the shell variable PATH, that is, a list of directory
>    names. When PYTHONPATH is not set, or when the file is not found there, the search continues
>    in an installation-dependent default path; on Unix, this is usually .:/usr/local/lib/python.
> 
>    Actually, modules are searched in the list of directories given by the variable sys.path which
>    is initialized from the directory containing the input script (or the current directory),
>    PYTHONPATH and the installation-dependent default. This allows Python programs that know what
>    they're doing to modify or replace the module search path. Note that because the directory
>    containing the script being run is on the search path, it is important that the script not
>    have the same name as a standard module, or Python will attempt to load the script as a module
>    when that module is imported. This will generally be an error. See section 6.2, ``Standard
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>    Modules,'' for more information.
> 
> Trochę drugi akapit (opisujący jak jest naprawdę) przeczy temu co jest w
> pierwszym, ale wszystko co trzeba jest udokumentowane.
dzieki. nie chce sie czepiac, ale nie do konca jest to udokumentowane.  nie
wiem co autor mial na mysli poprzez ,,this will generally will be an
error'' ale niestety python w takiej sytuacji nie zachowuje sie ladnie,
tzn. nie informuje ze skrypt probuje zaimportowac sam siebie, tylko
_importuje_ skrypt, co moze miec bardzo przykre konsekwencje
- w najlepszym przypadku bedziemy mieli jakis blad (niekoniecznie zwiazany
z importowaniem modulu), w najgorszym: bledne wyniki.

i zeby nie bylo, to ja zrobilem odpowiednia poprawke w ipython-ie naszym
i ja stracilem przez to deko czasu, wiec moge czuc sie lekko
poirytowany? :-P

jak juz powiedzialem: dla mnie eot, nie ma co bic piany. odpowiedni bcond
w cvs-ie, patch zgłoszony twórcom python-a.

    wrobell <wrobell w pld-linux.org>



Więcej informacji o liście dyskusyjnej pld-devel-pl