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

Carl Banks pavlovevidence at gmail.com
Tue Jun 9 03:28:38 CEST 2009


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):


Carl Banks



More information about the Python-list mailing list