finding a value in a tuple

Duncan Booth duncan at NOSPAMrcp.co.uk
Fri Nov 30 06:12:44 EST 2001


Chris Barker <chrishbarker at home.net> wrote in 
news:3C06AF9D.E6DEB295 at home.net:

> Actually, no. It is a "list". It would be a tuple if you had built it
> like this:
> 
> mylist = ('one','two','three')
> 
> Parentheses rather than square brackets. The difference is that lists
> are mutable (can be changed in place) and tuples care not.

Or even if you had built it thus:
   mylist = 'one', 'two', 'three'

The parentheses are not part of the tuple syntax (except for empty tuples): 
they are only required when the expression would otherwise be ambiguous.


-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list