Jump to content
Sign in to follow this  
  • entries
    73
  • comments
    131
  • views
    55060

Python #7 - Other data structures

Sign in to follow this  
okonomiyaki

124 views

I just read about 3 other data structures in Python: Tuples, Sets, and Dictionaries.

Sets and Dictionaries are pretty straightforward- a set is an unordered sequence of unique elements, and a dictionary is a sequence of key-value pairs.

But a tuple? What is the difference of a tuple and a list? The only difference I can see is that tuples are enclosed in parentheses and lists are enclosed in brackets. Also that tuples are immutable. Otherwise, indexing, slicing, etc. operations are the same. Maybe those are the only differences. Technically I know the difference but Python doesn't seem to differentiate them too much.
Sign in to follow this  


2 Comments


Recommended Comments

Tuples, unlike lists, can be used as dictionary keys, which have to be immutable.

Should a value not be changed, it's generally stored in a tuple, though that's more of an implication of use rather than a rule for obvious reasons.

Share this comment


Link to comment
Ah, I see. I suppose that's a pretty big difference, and could be important in cases such as dictionary keys.

Cool man. Thanks for all your comments!

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!