the demise of 'from foo import * and its implications?

Alex Martelli aleaxit at yahoo.com
Mon Mar 5 18:25:20 CET 2001


"Steve Holden" <sholden at holdenweb.com> wrote in message
news:suPo6.16824$ML1.841861 at e420r-atl2.usenetserver.com...
    [snip]
> I did begin to wonder whether it might be possible to specify a name
prefix,
> along the lines of
>
>     from modulewithaverylongname import * prefix sh_
>
> to allow
>
>     sh_i

But why not just
    import modulewithaverylongname as sh
and then use
      sh.i
...?

You can do that today, and the detailed semantics seem
likelier to be what is desired (e.g., should attribute
i of the module ever be re-bound, it's probably better
to automatically pick up the new reference, as happens
by using sh.i, than keep using the old one, as any
'from/import' approach would do -- marginal stuff, sure).


Alex






More information about the Python-list mailing list