4 ms·
It's quite possible to write code in a functional style in Python. Map pure lambdas over lazy, infinite sequences all you want. However, Python won't stop you
by heisenzombie 9y ago
It's quite possible to write code in a functional style in Python. Map pure lambdas over lazy, infinite sequences all you want. However, Python won't stop you writing code with spaghetti-like flow control and rampant side effects. Self-discipline is required. If you want to write only functional code, then you're definitely better off with a more rigid language that explicitly disallows mutation and side-effects.
However, if you subscribe to the idea that many real-world programs are naturally expressed as "a functional core inside an imperative shell"^1, then Python's stylistic flexibility might make it a good, practical choice.
1. https://gist.github.com/kbilsted/abdc017858cad68c3e7926b03646554e https://gist.github.com/kbilsted/abdc017858cad68c3e7926b0364...