Skip to content

Instantly share code, notes, and snippets.

@igilham igilham/
Created Jan 5, 2011

What would you like to do?
Read a random line from a file
#!/usr/bin/env python
import os
import random
import sys
def randline(fname):
result = ''
if os.path.exists(fname):
result = random.choice([line for line in open(fname)])
return result
def main(*args):
for arg in args[1:]:
return 0
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.