On Tue, Sep 7, 2010 at 10:02 AM, Phlip <[email protected]> wrote: > Back to the topic, I tend to do this: > > for record in Model.objects.filter(pk=42): > return record > > return sentinel
How is that any better than just catching the exception?
try:
return Model.objects.get(pk=42)
except Model.DoesNotExist:
return sentinel
The flow of control is much clearer this way.
Cheers,
Ian
--
http://mail.python.org/mailman/listinfo/python-list
