Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-13 Thread Arnaud Delobelle
Nobody nob...@nowhere.com writes: On Mon, 11 Oct 2010 05:42:39 -0700, Ethan Furman wrote: If I'm catching exceptions in order to perform clean-up, I'll use a bare except and re-raise the exception afterwards. In that situation, a bare except is usually the right thing to do. Wrong way to do

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-11 Thread Lawrence D'Oliveiro
In message pan.2010.10.05.20.44.49.109...@nowhere.com, Nobody wrote: If I'm catching exceptions in order to perform clean-up, I'll use a bare except and re-raise the exception afterwards. In that situation, a bare except is usually the right thing to do. Wrong way to do it. --

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-11 Thread Peter Otten
Steven D'Aprano wrote: On Tue, 05 Oct 2010 13:57:11 +1100, Ben Finney wrote: chad cdal...@gmail.com writes: while 1: A minor point: this is more explanatory and less misleading if you write it as ‘while True’. Why is it misleading? Is there some circumstance in Python where the

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-11 Thread Ethan Furman
Lawrence D'Oliveiro wrote: In message pan.2010.10.05.20.44.49.109...@nowhere.com, Nobody wrote: If I'm catching exceptions in order to perform clean-up, I'll use a bare except and re-raise the exception afterwards. In that situation, a bare except is usually the right thing to do. Wrong way

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-11 Thread Nobody
On Mon, 11 Oct 2010 05:42:39 -0700, Ethan Furman wrote: If I'm catching exceptions in order to perform clean-up, I'll use a bare except and re-raise the exception afterwards. In that situation, a bare except is usually the right thing to do. Wrong way to do it. What, then, is the right way

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-05 Thread Seebs
On 2010-10-05, Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: In message 87iq1hz6rc@benfinney.id.au, Ben Finney wrote: Don't ever use a bare ???except??? unless you know exactly why you're doing so. In other news, don???t ever put a loaded gun in your mouth and pull the

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-05 Thread Lawrence D'Oliveiro
In message slrnialg8v.28c5.usenet-nos...@guild.seebs.net, Seebs wrote: On 2010-10-05, Lawrence D'Oliveiro l...@geek-central.gen.new_zealand wrote: In message 87iq1hz6rc@benfinney.id.au, Ben Finney wrote: Don't ever use a bare ‘except’ unless you know exactly why you're doing so. In

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-05 Thread Steven D'Aprano
On Tue, 05 Oct 2010 11:13:53 +0800, Von wrote: Try to use sys.exit(0) Maybe you should print out the error in your except block. Not exiting with a status-code of 0 is no more helpful than not exiting with a status-code of 1. It's actually *less* helpful, if the intention is actually to exit

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-05 Thread Nobody
On Tue, 05 Oct 2010 13:57:11 +1100, Ben Finney wrote: Here's your problem. Don't ever use a bare ‘except’ unless you know exactly why you're doing so. Rather, figure out what exception types you want to catch, and catch *only* those types. If I use a bare except, I usually have a good reason,

I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread chad
Given the following.. #!/usr/bin/python import urllib2 import sys import time while 1: try: con = urllib2.urlopen(http://www.google.com;) data = con.read() print connected #The loop doesn't exit if I use sys.exit(1) break except:

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Justin Ezequiel
your bare except is catching the SystemExit raised by sys.exit(1) -- http://mail.python.org/mailman/listinfo/python-list

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Ben Finney
chad cdal...@gmail.com writes: while 1: A minor point: this is more explanatory and less misleading if you write it as ‘while True’. try: con = urllib2.urlopen(http://www.google.com;) data = con.read() print connected #The loop doesn't exit if I use

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Terry Reedy
On 10/4/2010 10:38 PM, chad wrote: Given the following.. #!/usr/bin/python import urllib2 import sys import time while 1: try: con = urllib2.urlopen(http://www.google.com;) data = con.read() print connected #The loop doesn't exit if I use sys.exit(1)

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Von
Try to use sys.exit(0) Maybe you should print out the error in your except block. 2010/10/5, chad cdal...@gmail.com: Given the following.. #!/usr/bin/python import urllib2 import sys import time while 1: try: con = urllib2.urlopen(http://www.google.com;) data =

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Steven D'Aprano
On Tue, 05 Oct 2010 13:57:11 +1100, Ben Finney wrote: chad cdal...@gmail.com writes: while 1: A minor point: this is more explanatory and less misleading if you write it as ‘while True’. Why is it misleading? Is there some circumstance in Python where the literal 1 could have a false

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Ben Finney
Steven D'Aprano steve-remove-t...@cybersource.com.au writes: Why is it misleading? Is there some circumstance in Python where the literal 1 could have a false value? It's misleading as to the intent. while 1 was the accepted idiom for infinite loops in Python for many years, before the

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-04 Thread Lawrence D'Oliveiro
In message 87iq1hz6rc@benfinney.id.au, Ben Finney wrote: Don't ever use a bare ‘except’ unless you know exactly why you're doing so. In other news, don’t ever put a loaded gun in your mouth and pull the trigger unless you know exactly why you’re doing so. Some people have a problem. They