Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100834

Idiom for this case?

Newsgroups comp.lang.python
Date 2015-12-24 14:04 -0800
Message-ID <86270a67-afff-42a4-a940-9f825fb57146@googlegroups.com> (permalink)
Subject Idiom for this case?
From KP <kai.peters@gmail.com>

Show all headers | View raw


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?

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Idiom for this case? KP <kai.peters@gmail.com> - 2015-12-24 14:04 -0800
  Re: Idiom for this case? Ben Finney <ben+python@benfinney.id.au> - 2015-12-25 09:30 +1100
  Re: Idiom for this case? Terry Reedy <tjreedy@udel.edu> - 2015-12-24 17:47 -0500

csiph-web