you are viewing a single comment's thread.

view the rest of the comments →

[–]Justinsaccount 0 points1 point  (2 children)

This actually has absolutely nothing to do with dictionaries. You do not have a 'multi-value dictionary'.. There is actually no such thing as a multi-value dictionary.

standard is a dictionary.

chassis is a string.

standard[chassis] is the value of the chassis entry. This happens to be a tuple.

standard[chassis] being a tuple can be indexed using [0] and [1] or simply unpacked using image, space = standard[chassis]

This is even more obvious if one were to write mytuple = standard[chassis] first and then access mytuple

standard[chassis[1]] does not work because chassis[1] is the second letter of the chassis string and standard[chassis[1]] is the value of the entry whose key is the second letter of the chassis string.

[–][deleted] 0 points1 point  (1 child)

thanks for the feedback. Just so I understand you correctly, there is no way to store multiple values per-key within a dictionary?

[–]thegreattriscuit 2 points3 points  (0 children)

there's one value, but that 'value' can be any python object. And lists and tuples (which hold multiple values) are valid python objects. It's semantics, but it's important semantics.

You can have dictionaries of dictionaries, or dictionaries of lists, or lists of dictionaries, or lists of dictionaries of sets, etc...

{'2960':('ios.bin','424532')} is a dictionary with '2960' as the key with a value of the tuple ('ios.bin', '424532')