[Python-ideas] Idea: Lazy ... statement

Jim Jewett jimjjewett at gmail.com
Tue Oct 14 22:10:31 CEST 2008


On Mon, Oct 13, 2008 at 4:12 AM, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

> So I think it would be good to have a dedicated syntax
> for lazy imports, so the top-level foo package can say
> something like

>  from foo.thing lazily import Thing
>  from foo.stuff lazily import Stuff

Since this can be (awkwardly) done now, I don't think the problem is
big enough for another keyword.  On the other hand, a "lazy" keyword
that worked in other contexts might have some merit.

That would solve at least one major objection to setdefault-style functions.

    def setdefault(self, k, lazy d=None): ...

or even

    lazy def yikes(msg):
        """Something went very wrong; report for debugging"""
        import logging
        ...logging config setup...
        ...

Note that I'm not yet ready to volunteer on fleshing out the details,
let alone how to implement it efficiently.   (Would it require the
moral equivalent of quasiquoting?)

-jJ



More information about the Python-ideas mailing list