Python 2.3.5 (#1, Mar 20 2005, 20:38:20) [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin Type "copyright", "credits" or "license()" for more information. **************************************************************** Personal firewall software may warn about the connection IDLE makes to its subprocess using this computer's internal loopback interface. This connection is not visible on any external interface and no data is sent to or received from the Internet. **************************************************************** IDLE 1.0 >>> conts = { "I've" : "I have", \ "I'll" : "I will", \ "I'm" : "I am" } >>> conts[ "I've" ] >>> print conts[ "I've" ] >>> conts[ 'won\'t' ] = 'will not' >>> conts # not ordered >>> dir(str) >>> help(str.replace) >>> x = [ i for i in conts ] >>> x >>> "I'll" in "this is a test of I'll contraction" >>> "I'm" in "this is a test of I'll contraction" >>> str = 'this is a test of I\'ll and won\'t and hasn\'t' >>> str >>> for i in conts: if i in str: str = str.replace( i, conts[i] ) >>> str >>> help(file) >>> f = file( 'contractions.txt', 'r') >>> stuff = f.read() >>> print stuff >>> for i in conts: if i in stuff: stuff = stuff.replace( i, conts[i] ) >>> print stuff >>> f.close()