preferring [] or () in list of error codes?

Charles Yeomans charles at declareSub.com
Mon Jun 8 21:56:53 EDT 2009


On Jun 8, 2009, at 9:28 PM, Carl Banks wrote:

> On Jun 8, 6:02 pm, Ben Finney <ben+pyt... at benfinney.id.au> wrote:
>> Carl Banks <pavlovevide... at gmail.com> writes:
>>> If you want to go strictly by the book, I would say he ought to be
>>> using a set since his collection of numbers has no meaningful order
>>> nor does it make sense to list any item twice.
>>
>> Yes, a set would be best for this specific situation.
>>
>>> I don't think it's very important, however, to stick to rules like
>>> that for objects that don't live for more than a single line of  
>>> code.
>>
>> It's important to the extent that it's important to express one's
>> *meaning*. Program code should be written primarily as a means of
>> communicating with other programmers, and only incidentally for the
>> computer to execute.
>
> Which is precisely why isn't not very important for an object that
> exists for one line.  No programmer is ever going to be confused about
> the meaning of this:
>
> if a in (1,2,3):
>

Actually, I might be -- I think of a tuple first as a single thing, as  
opposed to a list or map, which I see first as a collection of other  
things.

Charles Yeomans



More information about the Python-list mailing list