r/learnpython • • Mar 27 '23

Actually using a tuple

Can someone, please, give me a "real-world" example on the use of a tuple? I'm learning through w3schools. The idea of a tuple sort of makes sense, but I have no idea how it would/could be applied.

147 Upvotes

64 comments sorted by

View all comments

1

u/TheRNGuy Mar 27 '23 edited Mar 27 '23

I use for hard-coded confings in houdini HDA's. I don't ever change it in runtime so it doesn't need to be list.

Also, houdini's official API return tuple from some classes or methods (like mouse events in viewport)

other times, foo, bar = myfunc(). foo, bar is implicit tuple. Function could return tuple or list here.