Re: [Tutor] Trying to access a random value in a list

2012-01-12 Thread Nick W
first problem: easy fix just remember that len() returns the actual number of items in the list but that list is indexed starting at 0 so just replace your line of pick = len(names) with: pick = len(names) - 1 and for problem #2: just use string formating... like for example instead

Re: [Tutor] Set Reply-To field to Tutor@python.org

2013-01-29 Thread Nick W
My personal opinion (with whatever limited weight that has on this list since I've only answered a few questions - and probably half of them I've accidentally only sent to the op)/how I read it is that RFC 2822 actually allows lists to set reply-to header; by my view the list software is forwarding

Re: [Tutor] operator order

2013-01-31 Thread Nick W
because python process the expression on the right side of the assignment first. ie d *= 3+4 basically is the equivalent of writing (2) * (3+4). Hope that explains it. Nick On Thu, Jan 31, 2013 at 10:36 AM, heathen wrote: > why is this: > > >>> d = 2 > >>> d *= 3 + 4 > >>> d > 14 > > not this:

Re: [Tutor] Read from large text file, parse, find string, print string + line number to second text file.

2013-02-01 Thread Nick W
quite easy to do; just use enumerate - as so: myString = "The String" with open('largeFile', 'r') as inF: for index, line in enumerate(inF): #myString = "The String" ##Not here because otherwise this gets run for every single line of the large file (which is nasty waste of resources)

Re: [Tutor] Read from large text file, parse, find string, print string + line number to second text file.

2013-02-02 Thread Nick W
I'd suggest having the newfile open after outfile is defined also a close statement on newfile - or use it with 'with' such as: ... and replace the last line like so: with open(outfile, 'w') as newfile: main(mystring, infile, newfile) (and looking muchly improved, well done) Nick On Fri, Fe