Idiom for this case?

Terry Reedy tjreedy at udel.edu
Thu Dec 24 17:47:08 EST 2015


On 12/24/2015 5:04 PM, KP wrote:
> 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?

No.

-- 
Terry Jan Reedy




More information about the Python-list mailing list