It's working perfectly fine, you are just passing the wrong argument.
You are giving it bar, which identifies a function, so when it prints the argument it prints the string equivalent of what you passed it, which is the logical address of that function.
You want to pass it the result of your function you return, so instead of bar you're supposed to pass it bar(), which will run the function, return the string, and pass it along.
It works in the lambda because you are doing exactly that, executing the function instead of passing it directly.
It's nothing to do with pymel as much as understanding of some fairly fundamental concepts of Python