lambda in list comprehension acting funny
Daniel Fetchinson
fetchinson at googlemail.com
Wed Jul 11 02:41:57 EDT 2012
More information about the Python-list mailing list
Wed Jul 11 02:41:57 EDT 2012
- Previous message (by thread): Adding to a List and displaying quantity in the list
- Next message (by thread): lambda in list comprehension acting funny
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
funcs = [ lambda x: x**i for i in range( 5 ) ] print funcs[0]( 2 ) print funcs[1]( 2 ) print funcs[2]( 2 ) This gives me 16 16 16 When I was excepting 1 2 4 Does anyone know why? Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown
- Previous message (by thread): Adding to a List and displaying quantity in the list
- Next message (by thread): lambda in list comprehension acting funny
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list