I have a Python dict question where I struggle with using the typical tutorials I can find. In my debugger I see the following dict (call it instance_dict
in my code)
{
<segment_display.displayScore1>: {'show_43.segment_display_player.displayScore1': True},
<segment_display.displayScore2>: {'show_43.segment_display_player.displayScore2': True},
<segment_display.displayPlayer>: {'show_43.segment_display_player.displayPlayer': True},
<segment_display.displayScore3>: {'show_43.segment_display_player.displayScore3': True},
<segment_display.displayScore4>: {'show_43.segment_display_player.displayScore4': True},
<segment_display.displayBall>: {'show_43.segment_display_player.displayBall': True},
<segment_display.neoSegTopLine>: {},
<segment_display.neoSegBottomLine>: {}
}
Am I reading it correctly that for example <segment_display.displayScore1>
is the key, and that in this case the key is an object and not a string?
If that is correct, how do I understand the value {'show_43.segment_display_player.displayScore1': True}
is the value another dict object?
Now I run a for loop for a in instance_dict.items():
Now I want to get the value for each item. I thought I can do
instance_dict.get(a)
in my for loop to get the value -but that dumps. Of course I could do for a, b in ....
But why is my code dumping?
5
and that in this case the key is an object and not a string?
Yes and yes.
is the value another dict object?
Yes.