With a tuple, the value and type of items at each index of a
tuple may have significance, but successive items in a tuple rarely
have similar meanings.
With lists, successive items usually have similar meanings.
(Big analogy time): cars on a motorway might be modelled as a list of
car objects, but a car might be modelled as a tuple as the constituents
of a car might be treated differently:
style="font-family: monospace;"> style="font-weight: bold; color: rgb(255, 0, 0);">(engine,
seats, wheels, colour, valid_tax, speed, lights_on ,... style="font-weight: bold; color: rgb(255, 0, 0);">)
seats, wheels, colour, valid_tax, speed, lights_on ,... style="font-weight: bold; color: rgb(255, 0, 0);">)
wheras each car on a motorway might be treated in a similar
way:
style="font-family: monospace;">pull_over( car for cars in style="font-weight: bold; color: rgb(255, 0, 0);">[car1,
car2, ...] if not car[valid_tax_index style="font-weight: bold; color: rgb(255, 0, 0);">])
car2, ...] if not car[valid_tax_index style="font-weight: bold; color: rgb(255, 0, 0);">])
- Paddy.
No comments:
Post a Comment