The Samurai Principle
Benjamin Kaplan
benjamin.kaplan at case.edu
Tue Sep 7 19:38:13 EDT 2010
On Tue, Sep 7, 2010 at 6:20 PM, Phlip <phlip2005 at gmail.com> wrote:
> On Sep 7, 1:06 pm, Bruno Desthuilliers
> <bdesth.quelquech... at free.quelquepart.fr> wrote:
>
>> try:
>> return Model.objects.get(pk=42)
>> except Model.DoesNotExist:
>> return sentinel
>
> Visual Basic Classic had a Collection Class, which worked essentially
> like a real language's Hash, Map, or Dict.
>
> Except - it had no operation to test membership. It also could not
> enumerate by key and value (which would be 'for k,v in dict.items()').
> To test for membership, you _had_ to catch an exception - using VB's
> tragically clumsy exception model.
>
> Hours of fun. That leads us to this topic:
>
> http://www.google.com/search?q=don't+use+exceptions+for+normal+control+flow
> --
An experienced C programmer can program C in any language, but that
doesn't mean it's a good idea to.
When you're using a language, you should use the style that the
language emphasizes. While you shouldn't use exceptions for control
flow in C++, Java, or C#, there's nothing wrong with using them as
such in Python.
More information about the Python-list
mailing list