Skip to content

Instantly share code, notes, and snippets.

@cjwinchester
Created November 9, 2015 06:37
Show Gist options
  • Save cjwinchester/04e84652dbc2b41fcc6f to your computer and use it in GitHub Desktop.
Save cjwinchester/04e84652dbc2b41fcc6f to your computer and use it in GitHub Desktop.
"""
Unpacking a list of tuples to test for multiple replacement values. (Borrowed from a code snippet in "Mining the Social Web": http://shop.oreilly.com/product/0636920030195.do)
"""
REPLACE_LIST = [
(', Incorporated',', Inc.'),
(' Incorporated',' Inc.'),
(', LLC',''),
(' LLC',''),
(' Company',' Co.'),
]
TEST_STRING = "Time Warner, Incorporated, LLC"
for x in REPLACE_LIST:
TEST_STRING = TEST_STRING.replace(*x)
print TEST_STRING
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment