Relative Imports, why the hell is it so hard?
Terry Reedy
tjreedy at udel.edu
Tue Mar 31 20:04:28 EDT 2009
Kay Schluehr wrote:
> On 31 Mrz., 20:50, Terry Reedy <tjre... at udel.edu> wrote:
>>> Although the ceremony has been performed
>>> basically correct the interpreter god is not pacified and doesn't
>>> respond.
>> But the import 'ceremony' has not been performed.
>
> There is no import ceremony. Imports are just stated in the source.
> There is a package ceremony for whatever reasons.
Sorry, I have no idea what 'package ceremony' means.
>
>>> But why not? Because it looks up for *living* imported
>>> packages in the module cache ( in sys.modules ).
>>> I don't think there is any particular design idea behind it. The
>>> module cache is just a simple flat dictionary; a no-brainer to
>>> implement and efficient for look ups.
>> This all dates to the time before packages and imports from zip files
>> and such.
>>
>> > But it counteracts a domain model.
>>
>> What is that?
>
> Object oriented programming.
Domain model == oop? New one for me.
>>> All you are left with is those Finders, Loaders and Importers
>>> in Brett Cannons importlib. Everything remains deeply mysterious and I
>>> don't wonder that it took long for him to work this out.
>> And your proposal is?
>
> I have still more questions than answers.
OK. I will just note that import statements are syntactic sugar for
__import__ calls and name bindings. One could try out other import
schemes, just without the sugar.
tjr
More information about the Python-list
mailing list