Re: linecache and comparison with input

2007-06-30 Thread Ross Hetherington
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Sebastian Wiesner wrote: > Then you will see, that getline returns the line *including the newline > character*, while raw_input does not. Use line.strip('\n') to remove > trailing newline characters from the return value of getline. Ah, thank yo

linecache and comparison with input

2007-06-30 Thread Ross Hetherington
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Say I've got a file called 'testfile' that contains the following three lines: foo bar baz And a script that goes like this: #!/usr/bin/env python import random import sys import linecache rnd = random.randint(1,3) line = linecache.getline('test