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


Groups > comp.lang.python > #9490

Re: Please critique my script

From Peter Otten <__peter__@web.de>
Newsgroups comp.lang.python
Subject Re: Please critique my script
Followup-To comp.lang.python
Date 2011-07-14 22:53 +0200
Organization None
Message-ID <ivnkvv$jnn$1@solani.org> (permalink)
References <77AE044B1BF3944FAE2435F395F11B4B01859CD7@clt-exmb02.bbtnet.com> <mailman.1033.1310670724.1164.python-list@python.org>

Followups directed to: comp.lang.python

Show all headers | View raw


MRAB wrote:

>> for line2 in nxxReg.findall(soup):
>>     nxxlist.insert(count2, line2)
>>     count2 = count2 + 1
>>
> enumerate will help you here:

> for count2, line2 in enumerate(nxxReg.findall(soup)):
>     nxxlist.insert(count2, line2)
 
An insert() at the end of a list is usually spelt append() in Python ;)
If you are looking for something less baroque

nxxlist = nxxReg.findall(soup)

will do, too.

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


Thread

Re: Please critique my script MRAB <python@mrabarnett.plus.com> - 2011-07-14 20:12 +0100
  Re: Please critique my script Peter Otten <__peter__@web.de> - 2011-07-14 22:53 +0200
    Re: Please critique my script MRAB <python@mrabarnett.plus.com> - 2011-07-14 23:47 +0100

csiph-web