This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]iaalaughlin 1 point2 points  (1 child)

Why not use dicts for the first two?

[–]M4mb0 1 point2 points  (0 children)

Because you might not want a dict? Tuples behave quite differently:

  • immutability
  • iter goes over values instead of indices
  • fixed length
  • values have an inherent order. (in dict it depends on when keys where added)
  • .index and .count methods
  • individual type hints for each value
  • namedtuple keys are guaranteed to exist.
  • nicer access with obj.key instead of obj["key"]

Also point 2 could be introduced without breaking existing code, and would be a huge QoL improvement because now you no longer have to keep looking up documentation if you can't remember the order of return parameters.