Memorization with Python and Bubbles

I have found myself struggling to allocate time and patience to a very boring module that I am currently enrolled for (it’s a theory-only module). I have come up with a “lifehack” that allows me to proceed with my normal activities while keeping an eye on notes and memorizing. (This is literally something that was made in 10-15 min so go easy :P )


    # -*- coding: utf8 -*-

    import sys, os, subprocess
    from time import sleep

    quotes = []
    glossary = "glossary-boring-module.txt"  #<------- REPLACE PATH HERE
    MAX_LENGTH = 120

    def sendmessage(message):
        subprocess.Popen(['notify-send', message])

    def shortenedQuotes():
        global quotes
        new_array = []
        for quote in quotes:
            chunks = len(quote)/MAX_LENGTH
            for i in range(chunks):
                l = i * MAX_LENGTH
                r = l + MAX_LENGTH
        return new_array

    def getListOfQuotes():
        global glossary
        global quotes
        counter = -1
        if (os.stat(glossary)[6]!=0):
            for lines in open(glossary, 'r'):
                a = lines.strip()
            sendmessage("There are " + str(len(quotes)) + " quotes before shortening. Recalculating...")
            temp = shortenedQuotes()
            quotes = temp
            sendmessage("There are " + str(len(quotes)) + " quotes now. ")

            sendmessage("OOPS! THE LIST IS EMPTY!")

    def main():
        counter = 0
        answer = 'y'
        global contents
        if len(quotes) != 0:
            sendmessage("Displaying " + str(len(quotes)) + " businessquotes")
        for quote in quotes:
            counter = counter + 1
        sendmessage("No more quotes. Go to the terminal to repeat or terminate the script")

        if answer == raw_input("Please enter 'y' to continue or any other key to terminate"):

    if __name__ == '__main__':

The procedure is to scrape a file or page with definitions, save results in a .txt file and indicate the path to it in the script. Once run, the script then periodically displays definitions that - like it or not - you will start to memorize, in Ubuntu’s popup bubbles. If you have a different OS, don’t despair: except for creating the actual bubbles, the procedure is the same. It is still pretty buggy when it comes to managing very long chunks of text, (bubble real estate is very limited) but for simple ones this should be just fine. Obviously, there is no better code than one’s own so you’re most welcome to give it a stab and please share your tweaks, as will I. Cheers and happy memorization!

EDIT: I have now corrected the substring bug, and introduced a function that automatically splits a string into n strings not longer than the defined size limit. In other words, all you need to do is put all strings in a file, delimited by a newline, point the script to the file and run it in a terminal :)