stop script w/o exiting interpreter

Garrick.Peterson at zootweb.com Garrick.Peterson at zootweb.com
Mon Jan 29 11:22:36 EST 2007


> I want, and the script will stop executing at that line and will
> return to the interactive interpreter, as I wish.

May I recommend wrapping your main program in a function definition? Such 
as:

main():
        # Bulk of your code (use a macro to indent it faster)

if __name__ == "__main__":
        main()

Then you should be able to throw in a "return" at any point and get a 
clean break, without affecting the flow of your program. This should make 
it easier to debug as well, offering a clean entry point from the python 
interactive session, and letting you return a specific value you wish to 
check.


Garrick M. Peterson
Quality Assurance Analyst
Zoot Enterprises, Inc.
garrick.peterson at NO.zootweb.com

Copyright © 2007 Zoot Enterprises, Inc. and its affiliates.  All rights 
reserved. This email, including any attachments, is confidential and may 
not be redistributed without permission. If you are not an intended 
recipient, you have received this message in error; please notify us 
immediately by replying to this message and deleting it from your 
computer. Thank you. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070129/48134871/attachment.html>


More information about the Python-list mailing list