[Python-Dev] list of constants -> tuple of constants
Skip Montanaro
skip at pobox.com
Sun Feb 6 20:13:51 CET 2005
Raymond> [Skip]
>> If lists are conceptually like vectors or arrays in other languages
>> and tuples are like C structs or Pascal records, then by converting
>> from list to tuple form you've somehow muddied the data structure
>> water just to take advantage of tuples' immutability.
Raymond> In the context of literals used with the "in" operator,
Raymond> practices are widely divergent within the standard library and
Raymond> within the tutorial.
Then perhaps we should strive to make the standard library and tutorial more
consistent. Answers to questions on c.l.py often advocate the standard
library as a good source for example code.
Raymond> It seems that the list-as-arrays-tuple-as-records guideline is
Raymond> not meaningful or applicable in the context of the "in"
Raymond> operator. Proscribing tuple.__contains__ and tuple.__iter__
Raymond> carrys the notion a bit too far.
I agree that the presence of __contains__ and __iter__ kind of blurs the
distinction between the concept of sequence and struct.
Skip
More information about the Python-Dev
mailing list