Nobody 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
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
Lawrence D'Oliveiro wrote:
In message , 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.
What, then, is the right way to
Steven D'Aprano wrote:
> On Tue, 05 Oct 2010 13:57:11 +1100, Ben Finney wrote:
>
>> chad 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
> lit
In message , 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.
--
http://mail.python.org/mailman/listinfo/python-list
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 reaso
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 exi
In message , Seebs wrote:
> On 2010-10-05, Lawrence D'Oliveiro
> 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 pul
On 2010-10-05, Lawrence D'Oliveiro 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
> trigger unless you know exa
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. T
Steven D'Aprano 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 introduction of bools in (I think
On Tue, 05 Oct 2010 13:57:11 +1100, Ben Finney wrote:
> chad 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 value?
"whil
Try to use sys.exit(0)
Maybe you should print out the error in your except block.
2010/10/5, 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.re
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
chad 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 sys.exit(1)
your bare except is catching the SystemExit raised by sys.exit(1)
--
http://mail.python.org/mailman/listinfo/python-list
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:
time.s
17 matches
Mail list logo