Re: Method Call in Exception

2006-04-20 Thread Duncan Booth
Carl Banks wrote: In fact a lot of Pythonistas recommend this way over the alternative, even when you don't have to. For example, a lot of people recommend this: try: name = record.name except AttributeError: name = Freddy instead of this: if hasattr(record,name):

Re: Method Call in Exception

2006-04-20 Thread bruno at modulix
mwt wrote: (snip) This works when I try it, but I feel vaguely uneasy about putting method calls in exception blocks. What do you put in exception blocks?! Whatever fits the specific case... (snip) Normally I don't like to use exception blocks to do condition-statement stuff. At least that is

Re: Method Call in Exception

2006-04-20 Thread bwaha
mwt [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] In my latest attempt at some Python code, I've been tempted to write something in the form of: try: [...] #doing some internet stuff except IOError: alternate_method_that_doesnt_need_internet() I'm only a hack at

Re: Method Call in Exception

2006-04-20 Thread Kent Johnson
Carl Banks wrote: mwt wrote: In my latest attempt at some Python code, I've been tempted to write something in the form of: try: [...] #doing some internet stuff except IOError: alternate_method_that_doesnt_need_internet() This works when I try it, but I feel vaguely uneasy about

Method Call in Exception

2006-04-19 Thread mwt
In my latest attempt at some Python code, I've been tempted to write something in the form of: try: [...] #doing some internet stuff except IOError: alternate_method_that_doesnt_need_internet() This works when I try it, but I feel vaguely uneasy about putting method calls in exception

Re: Method Call in Exception

2006-04-19 Thread Felipe Almeida Lessa
Em Qua, 2006-04-19 às 16:54 -0700, mwt escreveu: This works when I try it, but I feel vaguely uneasy about putting method calls in exception blocks. What do you put in exception blocks?! So tell me, Brave Pythoneers, is this evil sorcery that I will end up regretting, or is it just plain

Re: Method Call in Exception

2006-04-19 Thread mwt
Felipe Almeida Lessa wrote: Em Qua, 2006-04-19 às 16:54 -0700, mwt escreveu: This works when I try it, but I feel vaguely uneasy about putting method calls in exception blocks. What do you put in exception blocks?! Usually I just print an error message. So tell me, Brave Pythoneers,

Re: Method Call in Exception

2006-04-19 Thread Serge Orlov
Felipe Almeida Lessa wrote: Em Qua, 2006-04-19 às 16:54 -0700, mwt escreveu: This works when I try it, but I feel vaguely uneasy about putting method calls in exception blocks. What do you put in exception blocks?! So tell me, Brave Pythoneers, is this evil sorcery that I will end up

Re: Method Call in Exception

2006-04-19 Thread Carl Banks
mwt wrote: In my latest attempt at some Python code, I've been tempted to write something in the form of: try: [...] #doing some internet stuff except IOError: alternate_method_that_doesnt_need_internet() This works when I try it, but I feel vaguely uneasy about putting method