This file contains hidden or 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 functools import wraps, partial | |
from inspect import getargspec | |
def _param_update(old_params, new_params): | |
args, kwargs = old_params | |
if type(new_params) == tuple: | |
if len(new_params) == 2 and type(new_params[0]) == tuple and type(new_params[1]) == dict: | |
args = new_params[0] | |
kwargs.update(new_params[1]) |
This file contains hidden or 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 functools import wraps, partial | |
from inspect import getargspec | |
def _param_update(old_params, new_params): | |
args, kwargs = old_params | |
if type(new_params) == tuple: | |
if len(new_params) == 2 and type(new_params[0]) == tuple and type(new_params[1]) == dict: | |
args = new_params[0] | |
kwargs.update(new_params[1]) |
This file contains hidden or 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
/api/get/player w/ post: { | |
'model': { | |
'id': 151, | |
'user': { | |
'id': int, | |
'email': str | |
}, | |
'name_first': str, | |
'name_last': str, | |
'short_name': str, # short_name is a method! |
This file contains hidden or 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
Domain Points Count Avg | |
techcrunch.com 32730 4305 7.60 | |
nytimes.com 28185 3827 7.36 | |
google.com 11049 1142 9.68 | |
wired.com 10397 1474 7.05 | |
paulgraham.com 7726 138 55.99 | |
37signals.com 7259 489 14.84 | |
wsj.com 6610 813 8.13 | |
readwriteweb.com 6421 1429 4.49 | |
arstechnica.com 5596 996 5.62 |
This file contains hidden or 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
mapping = lambda d: lambda x: d.get(x, x) |
This file contains hidden or 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 functools import wraps, partial | |
from inspect import getargspec | |
def _param_update(old_params, new_params): | |
args, kwargs = old_params | |
if type(new_params) == tuple: | |
if len(new_params) == 2 and type(new_params[0]) == tuple and type(new_params[1]) == dict: | |
args = new_params[0] | |
kwargs.update(new_params[1]) |
This file contains hidden or 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
>>> x = {} | |
>>> x['x'] = x | |
>>> x | |
{'x': {...}} |
This file contains hidden or 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 functools import wraps, partial | |
from inspect import getargspec | |
def _param_update(old_params, new_params): | |
args, kwds = old_params | |
if type(new_params) == tuple: | |
if len(new_params) == 2 and type(new_params[0]) == tuple and type(new_params[1]) == dict: | |
args = new_params[0] | |
kwds.update(new_params[1]) |
This file contains hidden or 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 functools import wraps | |
def predecoration(decoration=None, has_params=False): | |
"Decorates a function as a pre-decorator" | |
def metadecorator(decoration): | |
"Takes a decoration to pre-apply to a func" | |
def cap_args(*dec_args, **dec_kwds): | |
"Captures decorator arguments" | |
def decorator_with_args(func): |
This file contains hidden or 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
def validate(schema): | |
def validator(validatee): | |
for x in schema: | |
isValid = schema[x] | |
if type(validatee[x]) == isValid: continue | |
elif type(isValid) != type and hasattr(isValid, '__call__'): | |
if isValid(validatee[x]): continue | |
return False | |
return True | |
return validator |