Skip to content

Instantly share code, notes, and snippets.

Matt Bone thatmattbone

Block or report user

Report or block thatmattbone

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thatmattbone
thatmattbone / blog_example.py
Created May 4, 2012
a tour of python's ElementTree path language
View blog_example.py
#from thatmattbone.com
import sys
import trace
import xml.etree.ElementTree
from xml.etree.ElementPath import prepare_child, xpath_tokenizer
TEST_DOC = """
<root>
<a>
<b value="2"/>
@thatmattbone
thatmattbone / exec_fun.py
Created Apr 28, 2011
exec() yourself silly
View exec_fun.py
import random
class AreYouFeelingLuckyDict(dict):
"""A dictionary with a 50% chance of returning the thing you
actually put into it."""
exclude = set(["runs",
"NameError",
"True",
"random",
View lazily_evaluated_dict.py
class LazyDictionary(object):
def __init__(self, callback=dict):
self.data = None
self.callback = callback
def evaluate_callback(self):
self.data = self.callback()
def __getitem__(self, name):
You can’t perform that action at this time.