#!/usr/bin/python -tt # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 """A Python program to take the letters in the alphabet and produce a dictionary for the second version. """ import sys import re # Define a main() function that prints the dictionary. def main(): j = open('table.txt', 'rU') entries = re.split("\n",j.read()) print " dict = {}" for line in entries: match = re.match(r'(\w)\t(\w+)', line) if match: print " dict['" + match.group(1) + "'] = '" + match.group(2) + "'" # This is the standard boilerplate that calls the main() function. if __name__ == '__main__': main()