Is it ok to type check a boolean argument?
Scott David Daniels
Scott.Daniels at Acm.Org
Wed Jan 7 19:29:53 EST 2009
James Stroud wrote:
> ...
> def find(field, order_by='desc'):
> if order_by not in ['asc', 'desc']:
> raise ValueError, 'Bad order_by parameter.'
> ...
I'd try a little harder with that error message.
At least:
raise ValueError('Bad order_by parameter %r.' % (order_by,))
if not:
raise ValueError('Bad order_by = %r (should be in %r).' % (
order_by, ['asc', 'desc']))
--Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list