namespace question

Fredrik Lundh fredrik at pythonware.com
Tue Dec 12 02:10:39 EST 2006


jm.suresh at no.spam.gmail.com wrote:

> This one works. But I suppose there must be a way to artificially
> create a new block of code, some thing like this,
> 
> class Test:
>    c = None
>    <<howToCreateANewNameSpace>>:
>        # Objects created here are local to this scope
>        a = 1
>        b = 2
>        global c
>        c = a + b

if you want a local scope, use a function:

     class Test:
         c = do_calculation(1, 2)

</F>




More information about the Python-list mailing list