LAMBDA IS IT USELESS?

Ben Wolfson rumjuggler at cryptarchy.org
Sat Jul 14 15:15:37 EDT 2001


On Sat, 14 Jul 2001 17:55:25 GMT, bokr at accessone.com (Bengt Richter) wrote:

>From the grammar, we have
>    funcdef: 'def' NAME parameters ':' suite
>where
>    parameters: '(' [varargslist] ')'
>and
>    lambdef: 'lambda' [varargslist] ':' test
>
>So what would happen if that last "test" were
>changed to "suite" ? If the end of "suite" is
>well defined, why would there be a problem?

If that's *all* you do, this happens:

harper:~/tmp/Python-2.1.1c1> ./python
'import site' failed; use -v for traceback
Python 2.1.1c1 (#1, Jul 14 2001, 14:09:38)
[GCC 2.95.2 19991024 (release)] on sunos5
Type "copyright", "credits" or "license" for more information.
>>> t = lambda a:
...     if a == 1:
...             print 'hi'
...     else:
...             print 'bye'
...
>>> t
<function <lambda> at be4ac>
>>> t(1)
hi
Bus error
harper:~/tmp/Python-2.1.1c1>

-- 
Barnabas T. Rumjuggler
No man can run so fast that he can escape his own past's projectile vomit.



More information about the Python-list mailing list