[Tutor] Is there a test for hashability?
Richard D. Moores
rdmoores at gmail.com
Fri Sep 2 03:04:47 CEST 2011
Ah. I'll follow you with that.
Thanks,
Dick
On Thu, Sep 1, 2011 at 15:42, Chris Fuller
<cfuller084 at thinkingplanet.net> wrote:
> On Thursday 01 September 2011, Richard D. Moores wrote:
>> On Thu, Sep 1, 2011 at 12:29, Chris Fuller
>>
>> <cfuller084 at thinkingplanet.net> wrote:
>> > *Ahem*
>> >
>> > def is_hashable(object):
>> > try:
>> > hash(object)
>> > except TypeError:
>> > return False
>> >
>> > return True
>>
>> Why is that preferred to
>>
>> def is_hashable(object):
>> try:
>> hash(object)
>> return True
>> except TypeError:
>> return False
>>
>> ??
>>
>> Dick
>
> It's a style issue, really. Either would be fine, but I don't like mixing
> code-flow disrupting actions when it's easily avoided.
>
> Cheers
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list