if __name__ == 'main': & passing an arg to a class object

gtb goodTweetieBird at hotmail.com
Fri Apr 27 23:08:24 CEST 2007

The lines

if __name__ == 'main':

appear at the end of many examples I see. Is this to cause a .class
file to be generated?

The last line of the sample below has a string parameter. When I
mimicked this I got an error stating that the class constructor did
not take an arg, which seems correct.



# Generated by MaxQ [com.bitmechanic.maxq.generator.CompactGenerator]
from CompactTest import CompactTest

class MaxQTest(CompactTest):
    # Recorded test actions.
    def runTest(self):
        self.msg('Test started')

    # ^^^ Insert new recordings here.  (Do not remove this line.)

# Code to load and run the test
if __name__ == 'main':

More information about the Python-list mailing list