Please critique my script

Chris Angelico rosuav at
Fri Jul 15 02:36:32 EDT 2011

On Fri, Jul 15, 2011 at 4:03 AM, Ellerbee, Edward <EEllerbee at> wrote:
> for makenewlist in range(0,count):
>     sortlist.append(npalist.pop(0) + nxxlist.pop(0))

This can alternatively be done with map():

sortlist = map(lambda x,y: x+y, npalist, nxxlist)

However, I'm not sure what your code is meant to do if the two lists
have differing numbers of elements (if the two regexps turn up
differing numbers of results). If you can assume that this won't
happen, the simple map call will do the job.

(It would have been a lot cleaner if Python exposed its operators as
functions. In Pike, that lambda would simply be `+ (backtick-plus).)

Chris Angelico

More information about the Python-list mailing list