3 ms·
Umm... Am I just interpreting you wrong? Python has map in the builtin namespace: >>> map(lambda x: x*5, range(5)) [0, 5, 10, 15, 20]
by nightpool 12y ago
Umm... Am I just interpreting you wrong? Python has map in the builtin namespace:
>>> map(lambda x: x*5, range(5))
[0, 5, 10, 15, 20]
- tptacek 12y agoPython obviously has those primitives (that's what I meant by the tradeoff between it and Golang) but Guido infamously discourages their use.
- nightpool 12y agoHmm, sorry I didn't see this earlier, but I personally feel that Python supports a healthy mix of imperative, functional and object-oriented styles. (especially with the (over?) use of the "operators" library I tend to see around nowadays...) Certainly when I picked up a purely functional language (Racket) after mainly having only Python and Java experience before I didn't feel too disoriented or out of touch.
- burntsushi 12y agoThe parent is referring to the fact that Guido van Rossum (the Benevolent Dictator For Life of Python) is pretty down on functional programming in Python. You can read some of the history (from the horse's mouth) here: http://python-history.blogspot.com/2009/04/origins-of-pythons-functional-features.html http://python-history.blogspot.com/2009/04/origins-of-python... TL;DR - "I have never considered Python to be heavily influenced by functional languages, no matter what people say or think." Python, IMO, has flutters of functional programming in it. But its broken closures, lack of uncripppled anonymous functions and lack of tail-call optimization are pretty damning strikes against calling Python's support for functional programming similar to its support for imperative or OO paradigms. It just isn't. Yeah, we get `map` and `filter`, big whoop. :-)
- masklinn 12y ago> But its broken closures They were "unbroken" in Python 3, though because of the way scoping works in the language it requires marking variables (with `nonlocal`)
- burntsushi 12y agoI'm aware. The presence of nonlocal and global still makes them broken to me, even if it's a result of how scoping works. Lua and Javascript both manage to have unbroken closures.
- masklinn 12y ago> Lua and Javascript both manage to have unbroken closures. Because they use explicit local declaration (and implicitly declared variables are global in both)…
- ufo 12y agoYes, and I would say that requiring explicit local declarations is the right thing to do. Having a "default" variable scope is very error prone (typos are treated as new variables and closures don't work right) but at least with "global by default" you can use a linter to enforce that all your globals are explicitly declared. In Python its impossible to do something similar.
- masklinn 12y ago> Yes, and I would say that requiring explicit local declarations is the right thing to do. And I could hardly agree more with that, I simply disagree that Python's closures remain broken, they're simply fixed within the constraints set by previous design decisions. > at least with "global by default" you can use a linter to enforce that all your globals are explicitly declared Still, there's really no excuse for global as default, there's no convenience justification and could just as easily be an error (more easily really)
- 12y ago
- lmm 12y agoGuido discourages map because it should usually be expressed as a comprehension, no?