[Python-Dev] Relative import (original) (raw)

Ken Manheimer klm at zope.com
Wed Dec 17 18:57:23 EST 2003


On Thu, 18 Dec 2003, Greg Ewing wrote:

Thinking about the doubleunderscore names, it might not be so bad if they were a bit shorter, e.g.

A: root.P.Q B: here.P.Q here.parent.P.Q C: P.Q

Why separate here and parent? (I may just be confused, here.) Aren't both about getting the relative package container? Discussing schemes for explicit relative and absolute imports with some colleagues a few days ago, we liked 'pkg' for the package containing the current module - and pkg.pkg to mean its' container (and so on, for those non-programmers out there:-). Someone also wanted explicit expression of absolute, which we thought might be 'python'.

A: python.P.Q B: pkg.P.Q pkg.pkg.P.Q C: P.Q

That said, i much prefer the leading '.' scheme - i think the underscores are distinctly not easier to read, and i'm not bothered, anyway, by the "punctuality" of the leading-'.' - i think it stands out enough to be noticable, and the fractured-path implication of it conveys the relativeness...

Ken klm at zope.com



More information about the Python-Dev mailing list