__file__ for relative imports

Michael Hudson mwh at python.net
Fri Mar 22 04:51:28 EST 2002


Ken Seehof <kseehof at neuralintegrator.com> writes:

> > Robin Becker <robin at jessikat.fsnet.co.uk> writes:
> > 
> > > Is there an obvious reason why modules imported from the current
> > > directory don't have an absolute pathname for __file__?
> > 
> > No.  I think there's a bug on sf about this.
> > 
> > It would be a bit of a pest to implement, I think, but I may be
> > missing something.
> > 
> > Cheers,
> > M.
> 
> I keep bumping into that one too.  I can't think of any advantage
> for the current semantics, so I am submitting a PEP.  I didn't see
> a bug in sf or an existing PEP, but I might have missed something
> so please let me know.  Seems like a PEP is more appropriate than
> a bug report though.

It's here:

    http://www.python.org/sf/415492 

> I can't think of any reason for it to be difficult to implement.
> Seems like the code that assigns to __file__ in the first place
> could simply call abspath(), which should give correct results at
> load time.

Now explain how you import os.path.

Cheers,
M.

-- 
  ... when all the programmes on all the channels actually were made
  by actors with cleft pallettes speaking lines by dyslexic writers
  filmed by blind cameramen instead of merely seeming like that, it
  somehow made the whole thing more worthwhile.   -- HHGTG, Episode 11



More information about the Python-list mailing list