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
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.
--
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
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
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
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
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
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
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,
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:
your bare except is catching the SystemExit raised by sys.exit(1)
--
http://mail.python.org/mailman/listinfo/python-list
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
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)
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 =
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
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
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
17 matches
Mail list logo