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


Groups > comp.lang.python > #38778 > unrolled thread

A better way to accomplish loop

Started by"Joseph L. Casale" <jcasale@activenetwerx.com>
First post2013-02-12 19:59 +0000
Last post2013-02-12 19:59 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

#38778 — A better way to accomplish loop

From"Joseph L. Casale" <jcasale@activenetwerx.com>
Date2013-02-12 19:59 +0000
SubjectA better way to accomplish loop
Message-ID<mailman.1721.1360699255.2939.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web