victorsubervi at gmail.com
Wed Dec 30 14:50:55 CET 2009
On Wed, Dec 30, 2009 at 9:23 AM, Jean-Michel Pichavant <
jeanmichel at sequans.com> wrote:
> Victor Subervi wrote:
> On Wed, Dec 30, 2009 at 9:09 AM, Victor Subervi <victorsubervi at gmail.com<mailto:
>> victorsubervi at gmail.com>> wrote:
>> Anyway, you should definitely use a coding rule checker, like
>> pylint or pyckeck. It would sometimes point you into the correct
>> direction. For instance, pylint will tell you that except: pass is
>> often (not always) a clue for bad design/pattern and issue
>> warnings for it.
>> How about this:
>> id = form.getfirst('id')
>> sql = 'update %s set ProdID="%s" Quantity="%s" %s where ID="%s";' %
>> (tmpTable, prodid, quantity, sqlUpdateMiddle, id)
>> How does one get around sql calls that fail?
>> Rule N° 1:
> put the minimum code in try blocks
> Rule N°2:
> dont use BARE EXCEPT, or you'll piss off MRAB for good :o). Beside from
> kidding, don't use bare except.
> id = form.getfirst('id')
> sql = 'update %s set ProdID="%s" Quantity="%s" %s where ID="%s";' %
> (tmpTable, prodid, quantity, sqlUpdateMiddle, id)
> except NAME_OF_THE_EXCEPTION :
> raise # reraising without doing anything else is meaninless, you could
> remove the try block
> In your example you must lookt at your sql module documentation to know
> which kind of exception it can throw.
Or just throw the exception once and grab it. Okay, thanks ;)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list