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


Groups > comp.lang.python > #38778

A better way to accomplish loop

From "Joseph L. Casale" <jcasale@activenetwerx.com>
Subject A better way to accomplish loop
Date 2013-02-12 19:59 +0000
Newsgroups comp.lang.python
Message-ID <mailman.1721.1360699255.2939.python-list@python.org> (permalink)

Show all headers | View raw


I have an issue with some code I have been passed:

for (x, y) in [(a_dict1, a_tuple[0]), (a_dict2, a_tuple[1])]:


I only noticed it as PyCharm failed to assign the str type to y, whereas it knew
the tuples 0 and 1 item were type str.


In the loop it flags the passing of y into a method that expects type str. I can ignore
it, but looking at the loop, I cant help but think there is a better way?


Any guidance would be appreciated!
jlc

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


Thread

A better way to accomplish loop "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-02-12 19:59 +0000

csiph-web