Created
June 29, 2010 18:39
-
-
Save swanson/457604 to your computer and use it in GitHub Desktop.
Stone soup and boiled frogs
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
from BeautifulSoup import BeautifulStoneSoup | |
class Villager(object): | |
"""Just a gullible simpleton...""" | |
@staticmethod | |
def throw_in_pot(pot, item): | |
pot.append(item) | |
pot = ["<StoneSoup>", "<ingredients> stones"] | |
for ingredient in ['carrots', 'potatoes', 'beef', 'leeks', 'salt', 'herbs']: | |
Villager.throw_in_pot(pot, ingredient) | |
soup = BeautifulStoneSoup(' '.join(pot)) | |
print soup.prettify() | |
#<stonesoup> | |
# <ingredients> | |
# stones carrots potatoes beef leeks salt herbs | |
# </ingredients> | |
#</stonesoup> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment