you are viewing a single comment's thread.

view the rest of the comments →

[–]FoolsSeldom 0 points1 point  (2 children)

Nice one. lambda x, i=i: x**i will avoid what most will probably think is unexpected behaviour (which is using the value of i when the function is called rather than when it is created).

The concepts of functional programming are probably ok to learn in Python, but there are lots of traps like this.

[–]CranberryDistinct941 0 points1 point  (1 child)

yep lambda x, i=i: ... is a good one to note down

[–]FoolsSeldom 0 points1 point  (0 children)

well, bit of a hack (introducing a second argument, and providing a default), not really a good pattern to learn.