Skip to content

Instantly share code, notes, and snippets.

@swanson
Created June 29, 2010 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swanson/457604 to your computer and use it in GitHub Desktop.
Save swanson/457604 to your computer and use it in GitHub Desktop.
Stone soup and boiled frogs
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