On Thu, 06 Dec 2012 03:22:53 +0000, Rotwang wrote:

> On 06/12/2012 00:19, Bruno Dupuis wrote:
>> [...]
>>
>> Another advice: never ever
>>
>> except XXXError:
>>      pass
>>
>> at least log, or count, or warn, or anything, but don't pass.
> 
> Really? I've used that kind of thing several times in my code. For
> example, there's a point where I have a list of strings and I want to
> create a list of those ints that are represented in string form in my
> list, so I do this:
> 
> listofints = []
> for k in listofstrings:
>       try:
>               listofints.append(int(k))
>       except ValueError:
>               pass
> 
> Another example: I have a dialog box with an entry field where the user
> can specify a colour by entering a string, and a preview box showing the
> colour. I want the preview to automatically update when the user has
> finished entering a valid colour string, so whenever the entry field is
> modified I call this:
> 
> def preview(*args):
>       try:
>               previewbox.config(bg = str(entryfield.get()))
>       except tk.TclError:
>               pass
> 
> Is there a problem with either of the above? If so, what should I do
> instead?

They're fine.

Never, ever say that people should never, ever do something.


*cough*


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to