Proposal: Inline Import

Robert Kern robert.kern at gmail.com
Sat Dec 10 22:40:08 EST 2005


Bengt Richter wrote:

> Are you willing to type a one-letter prefix to your .re ? E.g.,
> 
>  >>> class I(object):
>  ...     def __getattr__(self, attr):
>  ...         return __import__(attr)

[snip]

> There are special caveats re imports in threads, but otherwise
> I don't know of any significant downsides to importing at various
> points of need in the code. The actual import is only done the first time,
> so it's effectively just a lookup in sys.modules from there on.
> Am I missing something?

Packages.

-- 
Robert Kern
robert.kern at gmail.com

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Python-list mailing list