preferring [] or () in list of error codes?
Emile van Sebille
emile at fenx.com
Tue Jun 9 01:30:17 EDT 2009
On 6/8/2009 8:43 PM Ben Finney said...
> Steven D'Aprano <steven at REMOVE.THIS.cybersource.com.au> writes:
>
>> In addition, using a tuple or a list in this context:
>>
>> if e.message.code in (25401,25402,25408):
>>
>> is so idiomatic, that using a set in it's place would be distracting.
>
> I think a list in that context is fine, and that's the idiom I see far
> more often than a tuple.
>
>> Rather that efficiently communicating the programmer's intention, it
>> would raise in my mind the question "that's strange, why are they
>> using a set there instead of a tuple?".
>
> The fact that literal set syntax is a relative newcomer is the primary
> reason for that, I'd wager.
>
Well, no. It really is more, "that's odd... why use set?"
Emile
More information about the Python-list
mailing list