'import x as y' stops the show (was: Re: [Python-Dev] [Patch #101135] 'import x as y' and 'from x import y as z' (fwd))

Peter Schneider-Kamp nowonder@nowonder.de
Thu, 10 Aug 2000 08:52:31 +0000


Thomas Wouters wrote:
> 
> On Thu, Aug 10, 2000 at 08:10:13AM +0000, Peter Schneider-Kamp wrote:
> > An even better way of doing this were if it would not
> > only give you another name but if it would not import
> > the original one. In this example our expression
> > would import all the symbols from Tkinter but would
> > rename createtimerhandle as tk_timer. In this way you
> > could still use * if you have a namespace clash. E.g.:
> 
> No, that isn't possible. You can't pass a list of names to 'FROM_IMPORT *'
> to omit loading them. (That's also the reason the patch needs a new opcode,
> because you can't pass both the name to be imported from a module and the
> name it should be stored at, to the FROM_IMPORT bytecode :)

Yes, it is possible. But as you correctly point out, not
without some serious changes to compile.c and ceval.c.

As we both agree (trying to channel you) it is not worth it
to make 'from import *' more usable, I think we should stop
this discussion before somebody thinks we seriously want
to do this.

Peter
--
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter@schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de