#! usr/bin/python import shelve quotes = ['insert your quotes here', 'they should use single quotes', 'there is a comma separating them'] database = shelve.open('/path/to/quotes.dat') try: database['index'] except: database['index'] = 0 finally: index = database['index'] database['index'] = (index + 1) % len(quotes) database.close() print quotes[index]