[Tutor] RE: stopping at a break point

Simon Brunning SBrunning@trisystems.co.uk
Thu, 7 Dec 2000 09:30:34 -0000


> From:	Mallett, Roger [SMTP:rmallett@rational.com]
> Here is my ugly snippet that enables me run the code in the debugger so
> that
> I can stop at break point.  Can someone please tell me why it works so I
> can
> understand it and clean it up?
> 
> 
> if __name__ == '__main__':
>     Main()
> else:
>     Main()  
 
This is the usual way of getting your script to behave differently depending
upon whether the script is imported, or run directly. __name__ is '__main__'
if the module is being run directly (i.e. You typed 'Python mymodule.py' at
the command line in order to run it, or some such). Hitting the run button
on the PythonWin toolbar runs you module in this way.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning@trisystems.co.uk




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.