Categories
Code

A little something for my GF

 

#!/usr/bin/env python
'''
This is made for my wonderfull girlfriend.
'''
try:
    import psyco
    psyco.full()
    import random
except:
    import random
        
def getBooks(file):
    import os
    f = open(os.path.join(os.path.curdir,file),'r')
    books = []
    for line in f.readlines():
        books.append(line)
    return books

def shuffel(books):
    num = random.randint(0,len(books)-1)
    result = books[num] + ", Number of books in list %s" %len(books)
    return result
    
def main():
    print(shuffel(getBooks('books.txt')))
    raw_input()

if __name__ == '__main__':
    main()  

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.