the demise of 'from foo import * and its implications?
Marcin 'Qrczak' Kowalczyk
qrczak at knm.org.pl
Mon Mar 5 17:25:28 EST 2001
Mon, 5 Mar 2001 11:47:51 -0500, Steve Holden <sholden at holdenweb.com> pisze:
> 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
import modulewithaverylongname as sh
for name in dir(sh): globals()['sh_'+name] = getattr(sh, name)
del sh
I don't see why do to this, and it's certainly not a feature to go
into the standard language.
An opposite trick can be used if a module is designed to be
star-imported and uses name prefixes, but we dislike star-import.
We can remove prefixes while moving objects to a separate namespace.
--
__("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK
More information about the Python-list
mailing list