#!/usr/bin/env python
import sys, re, operator, string

#
# The One class for this example
#
class TFTheOne:
    def __init__(self, v):
        self._value = v

    def bind(self, func):
        self._value = func(self._value)
        return self

    def printme(self):
        print self._value

#
# The functions
#
def read_file(path_to_file):
    with open(path_to_file) as f:
        data = f.read()
    return data

def filter_chars(str_data):
    pattern = re.compile('[\W_]+')
    return pattern.sub(' ', str_data)

def normalize(str_data):
    return str_data.lower()

def scan(str_data):
    return str_data.split()

def remove_stop_words(word_list):
    with open('../stop_words.txt') as f:
        stop_words = f.read().split(',')
    # add single-letter words
    stop_words.extend(list(string.ascii_lowercase))
    return [w for w in word_list if not w in stop_words]

def frequencies(word_list):
    word_freqs = {}
    for w in word_list:
        if w in word_freqs:
            word_freqs[w] += 1
        else:
            word_freqs[w] = 1
    return word_freqs

def sort(word_freq):
    return sorted(word_freq.iteritems(), key=operator.itemgetter(1), reverse=True)

def top25_freqs(word_freqs):
    top25 = ""
    for tf in word_freqs[0:25]:
        top25 += str(tf[0]) + ' - ' + str(tf[1]) + '\n'
    return top25

#
# The main function
#
TFTheOne(sys.argv[1]).bind(read_file).bind(filter_chars).bind(normalize).bind(scan).bind(remove_stop_words).bind(frequencies).bind(sort).bind(top25_freqs).printme()


@@ -1374,16 +1374,18 @@
 argv%5B1%5D)
+%5C%0A
 .bind(re
@@ -1392,16 +1392,18 @@
 ad_file)
+%5C%0A
 .bind(fi
@@ -1413,16 +1413,18 @@
 r_chars)
+%5C%0A
 .bind(no
@@ -1431,16 +1431,18 @@
 rmalize)
+%5C%0A
 .bind(sc
@@ -1444,16 +1444,18 @@
 nd(scan)
+%5C%0A
 .bind(re
@@ -1470,16 +1470,18 @@
 p_words)
+%5C%0A
 .bind(fr
@@ -1490,16 +1490,18 @@
 uencies)
+%5C%0A
 .bind(so
@@ -1503,16 +1503,18 @@
 nd(sort)
+%5C%0A
 .bind(to
@@ -1523,16 +1523,18 @@
 5_freqs)
+%5C%0A
 .printme

Make the main code more readable