linecache and comparison with input
- From: Ross Hetherington <ross@xxxxxxxxxxxxxxxxxx>
- Date: Sat, 30 Jun 2007 15:13:58 +0100
-----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('testfile', rnd)
print line
gss = raw_input('Enter line: ',)
if gss == line:
print 'yes'
sys.exit()
else:
print 'no'
Even if the right word is entered, the script always prints `no'. Can
anyone explain why this happens?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFGhmUm0HlvQApfM3gRCl23AJ45cv7A0KVi2h8/cWmcCrg4X8HZOACfT6V8
IpXAzpD0jKnFFDEJEmOFvc4=
=UA5b
-----END PGP SIGNATURE-----
.
- Follow-Ups:
- Re: linecache and comparison with input
- From: Sebastian Wiesner
- Re: linecache and comparison with input
- Prev by Date: Re: shelve crashing under Win ME
- Next by Date: Re: linecache and comparison with input
- Previous by thread: shelve crashing under Win ME
- Next by thread: Re: linecache and comparison with input
- Index(es):
Relevant Pages
|