Please critique my script

Peter Otten __peter__ at web.de
Thu Jul 14 16:53:36 EDT 2011


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.




More information about the Python-list mailing list