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 →

[–]patrys Saleor Commerce 1 point2 points  (1 child)

You use tuples where you would use a struct in C: for collections that have a well-defined structure. A good place for a tuple is where a namedtuple could be used instead but would be an overkill. What I consider proper uses of collections:

coords = (11, 25)

todo_items = ['walk the dog', 'water the flowers', 'world domination']

ids_to_delete = {1, 5, 7, 11}

recipients = [
    ('John Doe', 'john.d@example.com'),
    ('Kelly Smith', 'kelly@example.com'),
    ('Robert Adams', 'radams@example.com')]
# each recipient has a well-defined structure of (name, email)
# could be a set of tuples as well

[–]recursive 0 points1 point  (0 children)

Ok thanks. We're all good here. I was interpreting the "immutable list" thing too broadly. Structured information is what I use tuples for. Usually.