Skip to content

Instantly share code, notes, and snippets.

View dlitvakb's full-sized avatar

David Litvak Bruno dlitvakb

View GitHub Profile
@dlitvakb
dlitvakb / gist:1590081
Created January 10, 2012 17:17
map vs list comprehension
import timeit
def strip(a_string):
return a_string.strip()
results_map = []
results_list_comprehension = []
comp_list = [' 123', ' 123', '123', '123 ','123 ']
def strip_map():
@dlitvakb
dlitvakb / gist:1585704
Created January 9, 2012 23:41
require.py
class Require(object):
@staticmethod
def assert_equals(expected, expectee, comment="")
try:
assert expected == expectee
except AssertionError:
comment = "%s, " if comment
raise AssertionError(comment + "expected: %r, but was: %r" % (expected, expectee))
class Entity(object):
errors = {}
validators = {}
def __init__(self, **kwargs):
for name, value in kwargs.iteritems():
try:
if self._is_extra_property(name, value):
self._extra_properties(name, value)