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
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): |
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
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", |
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 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"/> |