I've been attempting to learn python lately, and I decided I'd like a string representation of a lambda. I tried doing what seemed obvious at the time:
quux = lambda x: 1-abs(x)
print(quux) #<function <lambda> at 0xfacefedaf>
This was almost as helpful as JavaScript's function foo(){ <native code> }
.
What I was really hoping for was something that showed what the function actually did, such as:
<function <lambda>: x:1-abs(x)>
or simply the original
x:1-abs(x)
Python doesn't seem to have any uneval
function, and I'm not really sure where to look through the various lifesaving modules for something like it.
Other stuff I tried:
print(repr(quux))
print(str(quux))