This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'scott' | |
with open('massachusetts_municipalities.txt', 'r') as inf, open('interleaved_list2.txt', 'w') as out: | |
A,B,C =[],[],{} | |
A += [item.strip() for item in inf] | |
for item in A: | |
if not item[0] in C: C[item[0]] = [] | |
C[item[0]].append(item) | |
B += [C[key] for key in sorted(C)] | |
while B: | |
if [] in B: B.remove([]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import sys | |
def spinner(granularity): | |
"""Wraps a function in an ASCII spinner display loop. granularity | |
represents the number of times the function should be called | |
before moving the spinner.""" | |
spinner_chars = itertools.cycle("\|/-") | |
def make_spinner(f): | |
calls = {'x': 0} |