Scott David Daniels <scott.dani...@acm.org> writes: > 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']))
Why are people so reluctant to make error message templates clearer with named placeholders? valid_order_by_values = ['asc', 'desc'] if order_by not in valid_order_by_values: raise ValueError( 'Bad order_by parameter %(order_by)r, should be in %(valid_order_by_values)r' % vars()) -- \ “I love and treasure individuals as I meet them, I loathe and | `\ despise the groups they identify with and belong to.” —George | _o__) Carlin, 2007 | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list