Opening random line from file with random.shuffle()
synthespian
synthespian at uol.com.br
Wed Feb 13 19:52:18 EST 2002
Hello-
I need to get a random line from a file. I read in thins NG about a "poorly" documented random.shuffle(), but I can't get it to work:
#!/usr/local/bin/python2.0
import random
file = open('/xxxx/yyy/zzz.txt')
allLines = file.readlines()
file.close()
getLine = random.shuffle(allLines)
print getLine,
string = str(getLine)
print string,
All I get as output is
"None None"
Thanks for __any__ help!
Regs
Henry
----------------------
_________ 1001101010
| ^ ^ | /1111100110
| o o | / 0010100111
| v |/ 1110100111
| ----- |
\_______/
______________________
Micro$oft-Free Human
100% Debian GNU/Linux
----------------------
KMFMS
More information about the Python-list
mailing list