linecache and comparison with input



-----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-----
.



Relevant Pages

  • Re: passing web authentication to background wget jobs?
    ... You need GnuPG to verify this message ... > I have a daily cron job that runs a script with the following: ... > can't test it until the server restarts late tonight, ... Why do you want to restart apache for a simple change in ...
    (comp.os.linux.misc)
  • Re: named
    ... You need GnuPG to verify this message ... >> need help to create script for cron, whitch check every 5 min if named is ... you reboot to get a kernel update running. ... script, not if the daemon is actually running. ...
    (linux.redhat)
  • Re: Where to add X startup actions?
    ... David Abrahams wrote the following on 27.08.2006 20:33: ... xhost +local:acpid ... # This script is executed at the end of each multiuser runlevel. ... Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org ...
    (Ubuntu)
  • Re: Do arrays use up alot of memory space?
    ... | The script is residing in C:\rubytest which is not in any of the path ... | Tried it with the force option but no file move was ... Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org ...
    (comp.lang.ruby)
  • Re: executable but unreadable script?
    ... You need GnuPG to verify this message ... In comp.unix.shell Brock Filer suggested: ... A general way would be using 'sudo' to run the script. ...
    (comp.unix.shell)