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


Groups > comp.lang.python > #38778

A better way to accomplish loop

Path csiph.com!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <jcasale@activenetwerx.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.039
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'assign': 0.07; 'ignore': 0.13; 'passing': 0.15; '(x,': 0.16; 'appreciated!': 0.16; 'expects': 0.16; 'received:172.18.0': 0.16; 'to:name:python- list@python.org': 0.20; 'flags': 0.22; 'tuples': 0.22; 'skip:( 20': 0.28; 'noticed': 0.28; 'loop,': 0.29; 'str': 0.29; 'way?': 0.29; 'code': 0.31; 'to:addr:python-list': 0.33; 'there': 0.35; 'but': 0.36; 'guidance': 0.36; 'method': 0.36; 'item': 0.37; 'some': 0.38; 'to:addr:python.org': 0.39; 'help': 0.40; 'think': 0.40; 'received:unknown': 0.63; 'subject:better': 0.84; 'str.': 0.91
X-Cloudmark-SP-Filtered true
X-Cloudmark-SP-Result v=1.1 cv=3f4U5fHrZLLPCzJ96ldNbjtja1zQ0ih230F6vdsLr5s= c=1 sm=1 a=P90J6pEA2ccA:10 a=KAdk4VP_izgA:10 a=7PYXob_7ZXMA:10 a=BLceEmwcHowA:10 a=8nJEP1OIZ-IA:10 a=xqWC_Br6kY4A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=SydWqukAaKltG-gpDEYA:9 a=wPNLvfGTeEIA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117
From "Joseph L. Casale" <jcasale@activenetwerx.com>
To "python-list@python.org" <python-list@python.org>
Subject A better way to accomplish loop
Thread-Topic A better way to accomplish loop
Thread-Index AQHOCVsrLFsl3eZXVkm77Ht3xjoYRQ==
Date Tue, 12 Feb 2013 19:59:40 +0000
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [172.18.0.4]
Content-Type text/plain; charset="iso-8859-1"
Content-Transfer-Encoding quoted-printable
MIME-Version 1.0
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1721.1360699255.2939.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1360699255 news.xs4all.nl 6841 [2001:888:2000:d::a6]:51560
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:38778

Show key headers only | 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