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


Groups > comp.lang.python > #107985

Re: Code Opinion - Enumerate

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Stephen Hansen <me+python@ixokai.io>
Newsgroups comp.lang.python
Subject Re: Code Opinion - Enumerate
Date Sun, 01 May 2016 22:24:58 -0700
Lines 20
Message-ID <mailman.306.1462166700.32212.python-list@python.org> (permalink)
References <0a2a0652-85c2-4283-a3c4-3ca8bc4e5481@googlegroups.com> <1462166698.1168771.595278561.2A184D4B@webmail.messagingengine.com>
Mime-Version 1.0
Content-Type text/plain
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de VSoUUBhbBkXgz1uf3u3GeQdAzoJininDtdidDcZ/2MUQ==
Return-Path <me+python@ixokai.io>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'used.': 0.05; 'received:internal': 0.09; '(something': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'friend.': 0.22; 'stephen': 0.22; 'subject:Code': 0.22; 'header:In-Reply-To:1': 0.24; 'continually': 0.29; 'index,': 0.29; 'code': 0.30; "can't": 0.32; 'instead,': 0.33; 'comment': 0.35; 'item': 0.35; 'but': 0.36; 'too': 0.36; 'to:addr:python- list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'received:66': 0.38; 'to:addr:python.org': 0.40; 'your': 0.60; 'header:Message-Id:1': 0.61; 'hug': 0.84; 'increases': 0.93
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=ixokai.io; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=G1P3fOcCFAphLhIT6LnVVJeHDSw=; b=W6oSCf eWlPomizNeDIkMmUDnLR+4wgGyyEBViNT8J0Hz6jiDxFWzI5+soTSGA3eftqe8BN bCEHTTw83guf/n9yj4k1PH1vqlIscoZHV8FJsMN1ajstyDca7qlkKK+rAVygJZPC yEXyXmZNCkvRspNeR0yeDQ0yn5y5x6bnsHlP8=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=G1P3fOcCFAphLhI T6LnVVJeHDSw=; b=rgo8BqDyD2Xr3dNvXkO3ZP67zsXdU01w0kF9cc3kp++3L+E o2XUVXR/Whi/YkqAO1FhQ8qjSr+hPKAkuTlZaUkXoGQnJVovquQjR8ntz/naLnWc kPskzXpqXo49XuOKIvQAxV4KcMxrmpAphspFPXGWB11hk2yesZJRVtn6M9Mk=
X-Sasl-Enc HWO2CC88OZE2HEjWrmqlzTndyrJmNbUK+wIvxl5keVWZ 1462166698
X-Mailer MessagingEngine.com Webmail Interface - ajax-491eb5a4
In-Reply-To <0a2a0652-85c2-4283-a3c4-3ca8bc4e5481@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <1462166698.1168771.595278561.2A184D4B@webmail.messagingengine.com>
X-Mailman-Original-References <0a2a0652-85c2-4283-a3c4-3ca8bc4e5481@googlegroups.com>
Xref csiph.com comp.lang.python:107985

Show key headers only | View raw


On Sun, May 1, 2016, at 08:17 PM, Sayth Renshaw wrote:
> Just looking for your opinion on style would you write it like this
> continually calling range or would you use enumerate instead, or neither
> (something far better) ?

I can't comment on your specific code because there's too much noise to
it, but in general:

Using enumerate increases readability, and I use it whenever the idiom:

    for index, item in enumerate(thing):
        ...

is used.

Enumerate is your friend. Hug it.

-- 
Stephen Hansen
  m e @ i x o k a i . i o

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


Thread

Code Opinion - Enumerate Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-01 20:17 -0700
  Re: Code Opinion - Enumerate Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-01 20:37 -0700
  Re: Code Opinion - Enumerate Stephen Hansen <me+python@ixokai.io> - 2016-05-01 22:24 -0700
    Re: Code Opinion - Enumerate Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-01 23:28 -0700
  Re: Code Opinion - Enumerate Sayth Renshaw <flebber.crue@gmail.com> - 2016-05-02 00:52 -0700

csiph-web