Idiom for this case?

KP kai.peters at gmail.com
Thu Dec 24 17:04:40 EST 2015


Given:

cfg =  {'c': ('3840', '1024'),
       'p1': {'gpio': '1', 'id': '4', 'coord': ('0', '0', '1280', '1024')}, 
       'p2': {'gpio': '2', 'id': '5', 'coord': ('1280', '0', '2560', '1024')},
       'p3': {'gpio': '3', 'id': '6', 'coord': ('2560', '0', '3840', '1024')}}

for config in cfg:
    if config != 'canvas':
        print config

Is there an idiom that combines the 'for...' & the 'if..' lines into one?




More information about the Python-list mailing list