__file__ for relative imports
Ken Seehof
kseehof at neuralintegrator.com
Thu Mar 21 18:53:11 EST 2002
> 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.
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. Seems like this PEP would probably only require one
line of code.
- Ken Seehof <kseehof at neuralintegrator.com>
More information about the Python-list
mailing list