On Jun 8, 1:01 am, Stef Mientki <[EMAIL PROTECTED]> wrote: > Gerard Flanagan wrote: > > On Jun 7, 8:39 am, dmitrey <[EMAIL PROTECTED]> wrote: > >> Hi all, > >> I guess this question was asked many times before, but I don't know > >> keywords for web search. > > >> Thank you in advance, D. > > > import os > > > d1 = os.path.dirname(__file__) > > here I get an error "__file__" is not defined ??
The code must be run from a script or module. If you run it from an interactive prompt, then you will get a NameError. > d2 = os.path.dirname(os.__file__) > > here I get a completely different path ?? > Is it the path of the os module? You can expect pure Python modules to have a __file__ attribute, but not every module has one - see the docs. > > > print d1 > > print d2 > > This seems to work (but I doubt it's always working !! ) > print os.getcwd() > > so what's the real answer ? > > thanks, > Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list