2005年07月07日 星期四 15:17
看到SQLStorage.py有如下函数: getattr(aq_parent, 'UID', lambda: None)() 请问如何解释?
2005年07月07日 星期四 15:24
好象是从aq_parent从查找UID方法,如果没找到返回lambda(不过有些怪没有试),然后执行,因为后面有() 在 05-7-7,Person<person.lee at gmail.com> 写道: > 看到SQLStorage.py有如下函数: > getattr(aq_parent, 'UID', lambda: None)() > 请问如何解释? > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > > > -- I like python! My Donews Blog: http://www.donews.net/limodou New Google Maillist: http://groups-beta.google.com/group/python-cn
2005年07月07日 星期四 16:02
其实就相当于 try: aq_parent.UID() except AttributeError: pass lambda: None 就是一个返回None的函数 On 7/7/05, limodou <limodou at gmail.com> wrote: > 好象是从aq_parent从查找UID方法,如果没找到返回lambda(不过有些怪没有试),然后执行,因为后面有() > > 在 05-7-7,Person<person.lee at gmail.com> 写道: > > 看到SQLStorage.py有如下函数: > > getattr(aq_parent, 'UID', lambda: None)() > > 请问如何解释? > > > > _______________________________________________ > > python-chinese list > > python-chinese at lists.python.cn > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > -- > I like python! > My Donews Blog: http://www.donews.net/limodou > New Google Maillist: http://groups-beta.google.com/group/python-cn > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > > > -- Qiangning Hong I'm usually annoyed by IDEs because, for instance, they don't use VIM as an editor. Since I'm hooked to that, all IDEs I've used so far have failed to impress me. -- Sybren Stuvel @ c.l.python Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1>
2005年07月08日 星期五 16:43
lambda:None就是一个返回None的函数,确实如此: >>> f = lambda:None >>> print f() None 谢谢! 在 05-7-7,Qiangning Hong<hongqn at gmail.com> 写道: > 其实就相当于 > > try: > aq_parent.UID() > except AttributeError: > pass > > lambda: None 就是一个返回None的函数 > > > On 7/7/05, limodou <limodou at gmail.com> wrote: > > 好象是从aq_parent从查找UID方法,如果没找到返回lambda(不过有些怪没有试),然后执行,因为后面有() > > > > 在 05-7-7,Person<person.lee at gmail.com> 写道: > > > 看到SQLStorage.py有如下函数: > > > getattr(aq_parent, 'UID', lambda: None)() > > > 请问如何解释? > > > > > > _______________________________________________ > > > python-chinese list > > > python-chinese at lists.python.cn > > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > > > > > -- > > I like python! > > My Donews Blog: http://www.donews.net/limodou > > New Google Maillist: http://groups-beta.google.com/group/python-cn > > > > _______________________________________________ > > python-chinese list > > python-chinese at lists.python.cn > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > -- > Qiangning Hong > > I'm usually annoyed by IDEs because, for instance, they don't use VIM > as an editor. Since I'm hooked to that, all IDEs I've used so far have > failed to impress me. > -- Sybren Stuvel @ c.l.python > > Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1> > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > > >
Zeuux © 2025
京ICP备05028076号