Newbie trying to understand __name__=='__main__'
Hamish Lawson
hamish_lawson at yahoo.co.uk
Mon Sep 18 22:32:51 EDT 2000
Dan Schmidt wrote:
> You're putting that if statement inside the class, which seems really
> odd. I don't know if it's even legal.
Though it was the wrong thing for this situation, having an if
statement in a class definition is perfectly legal. This is quite a
nice feature as it lets you do things like conditionally define a class
at runtime.
class SomeClass:
if condition():
def someMethod(self):
print "Do it this way"
else:
def someMethod(self):
print "Do it the other way"
Hamish Lawson
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list