Re: Please critique my script

2011-07-16 Thread Peter Otten
Ellerbee, Edward wrote: > I've been working on this for 3 weeks as a project while I'm learning > python. It's ugly, only function in there is from a fellow lister, but > it works perfectly and does what it is intended to do. > > I'd love to hear comments on how I could improve this code, what wo

Re: Please critique my script

2011-07-15 Thread Chris Angelico
On Fri, Jul 15, 2011 at 5:19 PM, bruno.desthuilli...@gmail.com wrote: >> (It would have been a lot cleaner if Python exposed its operators as >> functions. > > from operator import add Ah yes, I forgot that module. Yep, that cleans up the code a bit. ChrisA -- http://mail.python.org/mailman/lis

Re: Please critique my script

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 8:36 am, Chris Angelico wrote: > This can alternatively be done with map(): > > sortlist = map(lambda x,y: x+y, npalist, nxxlist) > > > (It would have been a lot cleaner if Python exposed its operators as > functions. from operator import add -- http://mail.python.org/mailman/list

Re: Please critique my script

2011-07-14 Thread Chris Angelico
On Fri, Jul 15, 2011 at 4:03 AM, Ellerbee, Edward 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 i

Re: Please critique my script

2011-07-14 Thread MRAB
On 14/07/2011 21:53, Peter Otten wrote: 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

Re: Please critique my script

2011-07-14 Thread Peter Otten
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 appe

Re: Please critique my script

2011-07-14 Thread MRAB
[snip] raw_input() returns a string, so there's no need for these 3 lines: > y = str(y) > z = str(z) > p = str(p) > pagedef = ("http://www.localcallingguide.com/xmllocalprefix.php?npa="; + y + "&nxx=" + z) > print "Querying", pagedef > > #--Get info from NANPA.com -- > urllib2.inst

RE: Please critique my script

2011-07-14 Thread Gerald Britton
For me, there are some things I don't like much. One-character variable names stand out (tend to make the code hard to read). Violation of PEP 8 guidelines, especially wrt spacing. e.g. result.append("%s[%s]%s" % (lastprefix, tails, lastsuffix)) not result.append("%s[%s]%s"%(lastprefix,tails,l

Please critique my script

2011-07-14 Thread Ellerbee, Edward
I've been working on this for 3 weeks as a project while I'm learning python. It's ugly, only function in there is from a fellow lister, but it works perfectly and does what it is intended to do. I'd love to hear comments on how I could improve this code, what would be good to turn into a function