idiom for initialising variables

Rob Hall bloke at ii.net
Thu Nov 7 05:54:13 EST 2002


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

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



I also see:

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


Which is the correct idiom?  or is there a subtle difference I am missing?


Rob





More information about the Python-list mailing list