Module directory
Alex Martelli
aleaxit at yahoo.com
Fri Sep 8 18:26:51 EDT 2000
More information about the Python-list mailing list
Fri Sep 8 18:26:51 EDT 2000
- Previous message (by thread): Module directory
- Next message (by thread): editing in Unicode
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Gilles Lenfant" <glenfant at nospam-e-pack.net> wrote in message news:8pams8$8br$1 at reader1.imaginet.fr... > Alex, > > Thanks for the pointer but: > import os.path > print os.path.dirname(__file__) > Returns a name error on __file __ that is an attribute of a module and does > not take the current module as default module when not specified. As I already indicated to Gilles in email, the "main script" is not a module; the __file__ is a module attribute. sys.path[0] is where you'll find the path that was given to python for it to find the "main script" from; e.g., empty, if it found it in the current directory (or got it from stdin...). os.path.abspath() will change a relative path into an absolute one (Gilles tells me this does not work on NT, with Python 1.5.2, when the relative path is empty; it does work on 2.0, and I don't have a 1.5.2 around any more to check. But clearly, the workaround is obvious if this is indeed a bug on some 1.5.2 versions). Alex
- Previous message (by thread): Module directory
- Next message (by thread): editing in Unicode
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list