idiom for initialising variables

Andrew Koenig ark at research.att.com
Wed Nov 6 14:18:08 EST 2002


Rob> I'm just wondering on the correct python idiom for initialising variables.
Rob> I see some code like this:

Rob> class myClass:
Rob>     self.a = 1
Rob>     def __init__(self):
Rob>         ...more stuff here

I doubt it -- the assignment to "self.a" should fail here
because "self" is undefined at that point.

How about posting an actual example?

-- 
Andrew Koenig, ark at research.att.com, http://www.research.att.com/info/ark



More information about the Python-list mailing list