Newbie trying to understand __name__=='__main__'

Dan Schmidt dfan at
Mon Sep 18 21:47:14 CEST 2000

"Luc Lefebvre" <lefebvre at> writes:

| class Set:
|     if __name__=='__main__':
|         x=Set([1,2,3,4])

You're putting that if statement inside the class, which seems really
odd.  I don't know if it's even legal.  Try taking the 'main' part of
your program (the 'if' and everything after it), and outdenting it
back to column 1, at the 'top level'.

                 Dan Schmidt |
Honest Bob CD now available! |

More information about the Python-list mailing list