[FRPythoneers] Exiting the main code block

Ken Kinder kkinder at tridog.com
Fri Jun 1 13:29:14 MDT 2001


although, the

	while 1:
		foo = func()
		if not foo: break
		...

is very common. I do that all the time.

There was talk of something perl'ish in while loops like this:

	while foo = func():
		...

But I don't know what happened of it.

Uche Ogbuji wrote:
> 
> "J. Wayde Allen" wrote:
> >
> > Yesterday I was tinkering with a new program and had been thinking that
> > I'd like to simply terminate the program if certain conditions occur.  I
> > tried using a break statement, but that causes an error since I was
> > not in a loop.  I suppose I could do something like:
> >
> >    while 1:
> >       if condition == something: break
> >       otherwise do stuff
> >
> > Is there a better way to cause the main program block to terminate?
> 
> If I understand what you mean,
> 
> import sys
> sys.exit(status)
> 
> Where status is an integer returned to the operating system (just 0 if
> there's no error).
> 
> --
> Uche Ogbuji                               Principal Consultant
> uche.ogbuji at fourthought.com               +1 303 583 9900 x 101
> Fourthought, Inc.                         http://Fourthought.com
> 4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA
> Software-engineering, knowledge-management, XML, CORBA, Linux, Python
> _______________________________________________
> This message sent by the FRPythoneers mailing list.
> Unsubscribe: echo unsubscribe | FRPythoneers-request at lists.community.tummy.com
> URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2016 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.community.tummy.com/pipermail/frpythoneers/attachments/20010601/236f819f/attachment.bin>


More information about the FRPythoneers mailing list