I found an interesting problem why you are trying to do the following to call a golf code:
>>> f=lambda s,z=len(s): 5+z
>>> f("horse")
11
>>>
>>> def g(s,z=len(s)):
... print "z: ", z
... print "sum: ", 5+z
...
>>> g("horse")
z: 6
sum: 11
>>>
>>> len("horse") + 5
10
Creating a function in both directions seems to be initializing zas 6instead of the expected 5, why is this happening?
source
share