On Mon, Jun 8, 2009 at 2:36 PM, <m...@pixar.com> wrote: > Is there any reason to prefer one or the other of these statements? > > if e.message.code in [25401,25402,25408]: > if e.message.code in (25401,25402,25408): > > I'm currently using [], but only coz I think it's prettier > than ().
I like to use tuples / () if the sequence literal is ultimately static. Purely because in my mind that just makes it a little more clear-- a list is mutable, so I use it when it should be or may be mutated; if it never would, I use a tuple. It just seems clearer to me that way. But a tuple also takes up a little space in memory, so it's a bit more efficient that way. I have absolutely no idea if reading / checking for contents in a list vs tuple has any performance difference, but would suspect it'd be tiny (and probably irrelevant in a small case like that), but still. --S
-- http://mail.python.org/mailman/listinfo/python-list