[Python-Dev] Relative import

Tim Peters tim.one at comcast.net
Thu Dec 18 03:21:28 EST 2003


[Guido]
> ...
> I'm beginning to agree (uselessly) with Tim: import itself is a
> problem. :-)

Not useless at all -- that's bonding!  Technically useless but humanly
essential <wink>.

It's no mystery *why* import is "a problem", but I'm not sure insight
implies a cure:  it's one of the very few places in Python where you can't
explicitly say what you intend.  Even in an inheritance hierarchy from hell,
if I really don't want to chance that please.hit_me() will get satisfied
from a class other than BlackJack, I can force it easily --

    BlackJack.hit_me(please)

There aren't any names to spell "the roots" of all the places Python may
search to satisfy an import, so no way either to be explicit about intent.
In contrast, nobody can mistake what

    import java.util.Random;

intends.  It's not a deep thing, it's just being able to name the intended
context.  I confess I'm keener on that than on growing more ways to spell
more kinds of searches.




More information about the Python-Dev mailing list