[Import-sig] Re: [Python-Dev] Proposal for a modified import mechanism.
Gordon McMillan
gmcm@hypernet.com
Mon, 12 Nov 2001 09:06:28 -0500
Prabhu wrote:
> Okay, so what do you propose? What do you think is the best
> solution?? import, rimport, rrimport??
If I had access to Guido's time machine, I would probably
change things so:
import is "absolute import"
rimport is "relative import"
rrimport is "recursive relative import"
I don't, so I tend towards:
aimport is "absolute import"
rimport is "relative import"
rrimport is "recursive relative import"
and
import is
try: rimport
except ImportError:
aimport
I'm not delighted with these names (and avoid syntax debates
like the plague), but they seem much clearer than grafting
relative-path syntax onto package / module names. For one
thing, all the familiar (to Windows & *nix users) punctuation
characters are unusable. For another, mac reverses the
spellings (so <path-sep><name> is relative and <name> is
absolute).
My rather unreliable crystal ball tells me the number one
objection to this will be "Why should I have to spell it out - I
just want to import it". My reply to that would be the same as
my reply to those who don't want to be bothered by having to
choose a spelling for division: at the time you write the code,
you know exactly what you want. When your code runs, we
can only guess what you wanted.
- Gordon