Chinaunix
标题:
python中lambda的源代码
[打印本页]
作者:
boyeestudio
时间:
2006-04-09 10:39
标题:
python中lambda的源代码
觉得lambda的用法有点神,所以贴出来,有待进一步研究!
/*Python-ast.c*/
expr_ty
Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, PyArena
*arena)
{
expr_ty p;
if (!args) {
PyErr_SetString(PyExc_ValueError,
"field args is required for Lambda");
return NULL;
}
if (!body) {
PyErr_SetString(PyExc_ValueError,
"field body is required for Lambda");
return NULL;
}
p = (expr_ty)PyArena_Malloc(arena, sizeof(*p));
if (!p) {
PyErr_NoMemory();
return NULL;
}
p->kind = Lambda_kind;
p->v.Lambda.args = args;
p->v.Lambda.body = body;
p->lineno = lineno;
p->col_offset = col_offset;
return p;
}
本文来自ChinaUnix博客,如果查看原文请点:
http://blog.chinaunix.net/u/17118/showart_97193.html
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2