I want to help with understanding the commentary from Karl Knechtel (December 13-13 at 7:32). The following code shows how using a generator, the original lambda definition gives the result, but does not use a list or tuple:
>>>
... basis = ( (lambda x: n*x) for n in [0, 1, 2] )
>>> print(type(basis))
<type 'generator'>
>>> basis = ( (lambda x: n*x) for n in [0, 1, 2] )
>>> print([x(3) for x in basis])
[0, 3, 6]
>>>
... basis = tuple( (lambda x: n*x) for n in [0, 1, 2] )
>>> print(type(basis))
<type 'tuple'>
>>> print([x(3) for x in basis])
[6, 6, 6]
>>>
... basis = list( (lambda x: n*x) for n in [0, 1, 2] )
>>> print(type(basis))
<type 'list'>
>>> print([x(3) for x in basis])
[6, 6, 6]
>>>
... basis = list( (lambda x, n=n: n*x) for n in [0, 1, 2] )
>>> print(type(basis))
<type 'list'>
>>> print([x(3) for x in basis])
[0, 3, 6]
source
share