[Python-ideas] Object grabbing

Greg Ewing greg.ewing at canterbury.ac.nz
Mon May 2 01:55:13 EDT 2016


Joshua Morton wrote:
>     import math
>     with Namespace(math):  
>         print(pi**2)

That can't work if pi isn't assigned to as a local
somewhere else in the function, because the compiler
won't have allocated it a slot in locals for
Namespace to modify.

>     with Namespace(m=math):`
>         print(m.pi**2)

I don't see how that's any better than

    m = math
    print(m.pi**2)

-- 
Greg


More information about the Python-ideas mailing list