namespace question

Paul Boddie paul at boddie.org.uk
Wed Dec 13 06:39:36 EST 2006


jm.suresh at no.spam.gmail.com wrote:
> Yes. I want to have only one class variable called c and a and b are
> required as temporary variables to calculate the value for c.
>
> I just found one way:
> class Test:
>     a = 1
>     b = 2
>     c = a + b
>     del a,b

Or even...

a = 1
b = 2
class Test:
    c = a + b

Or even the apparently nonsensical...

a = 1
b = 2
c = a + b
class Test:
    c = c

Insert del statements to remove module globals where appropriate.

Paul




More information about the Python-list mailing list