Skip to content

Instantly share code, notes, and snippets.

thatmattbone /
Created May 4, 2012
a tour of python's ElementTree path language
import sys
import trace
import xml.etree.ElementTree
from xml.etree.ElementPath import prepare_child, xpath_tokenizer
TEST_DOC = """
<b value="2"/>
thatmattbone /
Created Apr 28, 2011
exec() yourself silly
import random
class AreYouFeelingLuckyDict(dict):
"""A dictionary with a 50% chance of returning the thing you
actually put into it."""
exclude = set(["runs",
class LazyDictionary(object):
def __init__(self, callback=dict): = None
self.callback = callback
def evaluate_callback(self): = self.callback()
def __getitem__(self, name):