01 | #!/usr/bin/env python |
02 | ''' |
03 | This is made for my wonderfull girlfriend. |
04 | ''' |
05 | try : |
06 | import psyco |
07 | psyco.full() |
08 | import random |
09 | except : |
10 | import random |
11 | |
12 | def getBooks( file ): |
13 | import os |
14 | f = open (os.path.join(os.path.curdir, file ), 'r' ) |
15 | books = [] |
16 | for line in f.readlines(): |
17 | books.append(line) |
18 | return books |
19 |
20 | def shuffel(books): |
21 | num = random.randint( 0 , len (books) - 1 ) |
22 | result = books[num] + ", Number of books in list %s" % len (books) |
23 | return result |
24 | |
25 | def main(): |
26 | print (shuffel(getBooks( 'books.txt' ))) |
27 | raw_input () |
28 |
29 | if __name__ = = '__main__' : |
30 | main() |