[Python-Dev] New universal import mechanism ( Re: [Python-checkins] python/dist/src/Python import.c,2.210,2.211)

David Abrahams dave@boost-consulting.com
Tue, 03 Dec 2002 09:45:24 -0500


"Samuele Pedroni" <pedronis@bluewin.ch> writes:

> From: "Jeff Epler" <jepler@unpythonic.net>
>
>> Currently __all__ is a list of all the attributes to be exported by the
>> module.  What if we let __all__ be a list (with its current
>> interpretation) or a callable.

<snip>

> I find this idea of a semantics change rather unpythonic;

Of course you do; look at Jeff's email address! Wish I'd thought of
establishing that one myself <wink>. Calling something "un-pythonic"
is a very convenient form of derision.

But seriously: it's not a semantics change, but an extension... unless
you think people are making __all__ callable today, and counting on an
exception from the import mechanism.

> ( 2nd in general should  not  import * be avoided ?)
>
> Why then only import * should have a user-defined behavior?
>
> What about
>
> from module import x

I had the same thoughts. I am not entirely convinced that what my user
has asked for is the best approach.

> if the importing module has already a defined x then maybe that
> should be also under user control?

I don't understand that suggestion. Care to elaborate?

> I'm surely missing something.

it ain't neccessarily so...

-- 
                       David Abrahams
   dave@boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution