Discussion:
[BitPim-devel] Re: [bitpim-cvs-checkins] bitpim common_calendar.py,1.2,1.3 vcal_calendar.py,1.5,1.6
Roger Binns
2005-02-05 06:18:28 UTC
Permalink
+ return '%04d-%02d-%02d'%v[:3]
+ return '%04d-%02d-%02d %02d:%02d'% v
+ return ''
That sort of code (catching all exceptions) is generally considered
bad form. The reason is that it can hide other errors. It
is generally better to catch only the exceptions you know could
occur and need to be ignored. You definitely don't want to ignore
things that could be the result of programming errors elsewhere.
(In fact many places have a coding style that bans catching all
exceptions - you must list the ones you are dealing with).

As an example, the above will silently swallow the exception
caused if v's elements are strings instead of integers.

Feel free to litter the code with assertions, but remember that
they are only processed when running from CVS. They are very
good for catching developer errors.

Roger

Loading...