get thing

This commit is contained in:
Paul Tagliamonte 2012-12-18 23:54:38 -05:00
parent bfb3ce8138
commit 196bd8cf98

View File

@ -26,6 +26,22 @@ def _add_native_methods(mod):
return ret return ret
def _foreach(*args):
a = args[0]
for arg in a:
args[1](arg)
def _get(*args):
m = args[0]
k = args[1]
if k in m:
return m[k]
else:
if len(args) > 2:
return args[2]
raise KeyError("No such key `%s` in map." % (k))
def _eval(*args): def _eval(*args):
ret = [] ret = []
for node in _lex(*args): for node in _lex(*args):
@ -132,6 +148,8 @@ def _add_native_methods(mod):
"eval": _eval, "eval": _eval,
"lex": _lex, "lex": _lex,
"read": _read, "read": _read,
"foreach": _foreach,
"get": _get
} }
for native in natives: for native in natives: