Python Defining Lists in Lists -


i trying define table colors contains various other tables containing tuples represent colors.

title_label = [ text = (236, 218, 51), background = (125, 142, 246) ], start_button = [ text = (32, 40, 145), background = (236, 235, 136), pressed = (44, 51, 112) ], quit_button = [ text = (166, 21, 13), background = (48, 61, 188), pressed = (31, 40, 129) ] 

however, gives invalid syntax error. why that?

lists don't take name-value pairs. want dictionaries here instead:

definitions = {     'title_label': {         'text': (236, 218, 51),         'background': (125, 142, 246)     },     'start_button': {         'text': (32, 40, 145),         'background': (236, 235, 136),         'pressed': (44, 51, 112)     },     'quit_button': {         'text': (166, 21, 13),         'background': (48, 61, 188),         'pressed': (31, 40, 129)     } } 

i'm not sure found syntax, not valid python. python lists, using [...] square brackets, can take sequence of individual python expressions:

some_list = ['one object', {'dictionary': 'value'}, ['another', 'list']] 

see data structures section of python tutorial.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -