Charming Python: Functional programming in Python
1–10 of 26 posts
Re: Charming Python: Functional programming in Python
#2Still not sure whether this is a good or bad thing.
Re: Charming Python: Functional programming in Python
#3Re: Charming Python: Functional programming in Python
#4why doesn't python have anonymous functions (not just lambdas which can only be expressions)?
It's considered opaque.
Personally, I like to fiddle with Clojure in my free time.
Re: Charming Python: Functional programming in Python
#5Re: Charming Python: Functional programming in Python
#6Ever since I've dabbled a bit with Lisp my Python (and javascript) code has become much more functional-y. Still not sure whether this is a good or bad thing.
Re: Charming Python: Functional programming in Python
#7why doesn't python have anonymous functions (not just lambdas which can only be expressions)?
Re: Charming Python: Functional programming in Python
#8why doesn't python have anonymous functions (not just lambdas which can only be expressions)?
Re: Charming Python: Functional programming in Python
#9Ever since I've dabbled a bit with Lisp my Python (and javascript) code has become much more functional-y. Still not sure whether this is a good or bad thing.
I've both written and read code in non-functional languages where the "easy" way of doing it is thrown aside for the "cool functional" way of doing it. Leading to code which was more fun to write, looks cooler, but is also hard to read and written in a different idiom to the actual programming language. Bad.
I'm 100% guilty of this, although I try to stay vigilant. The other day I refactored out a gnarly bit of a Python API, but caught myself feeling sad because it meant deleting a bunch of clever lambda functions I was using to work around it in the first place. Bad!
That said, the other side of the double-edged sword is great - things that lead to giant tangled messes of procedural code can be turned into very nice functional-style constructs. Also, I love having list comprehensions in Python.
Re: Charming Python: Functional programming in Python
#10why doesn't python have anonymous functions (not just lambdas which can only be expressions)?
It lets you define functions on the fly and use them, so the only difference from anonymous functions is that you have to pick a name.
def foo(x):
def lambda():
print x
lambda;bar(callback=lambda);baz(42,lambda)
def lambda():
print x * x
lambda;bar(callback=lambda);baz(42,lambda)
It'd stop this silly complaint. I just end up using 'def lambduh'Slightly annoying that you need to define the function on the line before, can't inline it, but not nearly as bad as people make it out to be.