Message1889
A little more exploratory work:
Jython 2.2:
>>> filter( lambda (x):x==1, [(1,),(2,)] )
[(1,)]
While in Python 2.4:
>>> filter( lambda (x):x==1, [(1,),(2,)] )
[]
In fact, in a simpler example,
In Jython 2.2:
>>> f = lambda (x):x
>>> f(1)
Traceback (innermost last):
File "<console>", line 1, in ?
File "<console>", line 1, in <lambda>
TypeError: iteration over non-sequence
>>> f((1,))
1
>>> f((1,2))
Traceback (innermost last):
File "<console>", line 1, in ?
File "<console>", line 1, in <lambda>
ValueError: unpack tuple of wrong size
>>>
While in Python 2.4:
>>> f = lambda (x):x
>>> f(1)
1
>>> f((1,))
(1,)
>>> f((1,2))
(1, 2)
>>>
It seems that Jython takes lambda (x) a little too literally, assuming that the argument passed will be only a single element tuple. While Python interprets it like any other function definition.
I will look into the matter further, time permitting.
HTH,
~musically_ut |
|
Date |
User |
Action |
Args |
2008-02-20 17:18:01 | admin | link | issue1784950 messages |
2008-02-20 17:18:01 | admin | create | |
|