New submission from Michal Vyskocil <mvysko...@suse.cz>: The compounded expressions with lambda functions are evaluated incorrectly. The simple expressions, or a named functions are evaluated good. The problem is only in the evaluation of compounded expressions. It seems that after evaluate of the first lambda function the evaluation of whole expression is stopped and not continue (see cond_error, which may raises the exception during evaluation).
Python 3.1 (r31:73572, Aug 15 2009, 22:04:19) [GCC 4.4.1 [gcc-4_4-branch revision 149935]] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> cond = (lambda x : x == 'foo') or (lambda x : x == 'bar') >>> cond('foo') True >>> cond('bar') False >>> c1 = lambda x : x == 'foo' >>> c1('foo') True >>> c2 = lambda x : x == 'bar' >>> c2('bar') True >>> def ham(x): return x == 'foo' ... >>> def spam(x): return x == 'bar' ... >>> cond2 = lambda x : ham(x) or spam(x) >>> cond2('foo') True >>> cond2('bar') True >>> cond2('ham') False >>> cond_error = (lambda x : x == 'foo') or (lambda x : y == 'bar') >>> cond_error('d') False BTW: the same problem exists in Python 2.6.2 Python 2.6.2 (r262:71600, Aug 15 2009, 18:37:04) [GCC 4.4.1 [gcc-4_4-branch revision 149935]] on linux2 Type "help", "copyright", "credits" or "license" for more information. ---------- messages: 91766 nosy: mvyskocil severity: normal status: open title: Compounded expressions with lambda functions are evaluated incorrectly versions: Python 3.1 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6740> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com