get thing
This commit is contained in:
parent
bfb3ce8138
commit
196bd8cf98
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user