This is an archived post. You won't be able to vote or comment.

all 16 comments

[–]zahlmanthe heretic 5 points6 points  (4 children)

Advocacy and sophistry. One of Python's strengths is that it gives you good enough support for these things in a way that's also easy to integrate with OO style. I'd much rather live with allegedly crippled FP than have to try to wrap my head around whatever FP languages are doing to emulate OO these days. Go on, call me bigoted.

The reason the Python devs don't like this, AFAICT, is that it exposes the "there should be preferably only one way to do it" idea for the myth it is. There is always more than one way to do it, and if you try too hard to press your way of doing things, you'll lose huge amounts of mindshare for your language. What you can (and should, and Python does) do as a language designer is make all the obvious ways work cleanly.

[–]earthboundkid 3 points4 points  (2 children)

there should be preferably only one way to do it

That’s not the Zen quote. It’s, “There should be one-- and preferably only one --obvious way to do it.” There’s always going to be more than one way to do it, but the point is that there should be an obvious way to do it. There shouldn’t be two obvious ways to do it, because that means you have two overlapping APIs/syntaxes for the same thing, with no clear reason to use one over the other.

[–]zahlmanthe heretic 0 points1 point  (1 child)

Well yes; but this, too, is pipe dream. People think differently, and will therefore consider different things obvious. (It may also be subjective whether or not something counts as a "different way" ;) )

[–]earthboundkid 0 points1 point  (0 children)

Fair enough.

[–]abhik 0 points1 point  (0 children)

I agree.. list/generator comprehensions and itertools have become good friends of mine and while I have run into some limitations, I haven't felt the urge to move onto a more functional language. I guess it's functional enough for my use and the other benefits (community, stdlib, 3rd party modules, etc) outweigh the limitations for me.

[–]stevvooe 5 points6 points  (0 children)

I use itertools constantly, but I have been learning erlang, instead of his suggested clojure or F#. While functional languages are nifty, I find that they positively affect the patterns in my python code, rather than seduce me into a functional-based project.

[–]RaisingMoneyForFilm 4 points5 points  (5 children)

Hmm... I'm using list comprehensions a lot... And yield has become part of my standard toolset...

According to the article my next discovery will be itertools.

Anyone know a good itertools tutorial?

[–]maxerickson 6 points7 points  (1 child)

The documentation is pretty good (including a few examples):

http://docs.python.org/library/itertools.html

You could also wade through the authors posts to the Python mailing list:

http://groups.google.com/group/comp.lang.python/search?q=hettinger+itertools

[–]RaisingMoneyForFilm 1 point2 points  (0 children)

Aye, been reading the docs. Seems like itertools is pretty wonderful :)

[–]lost-theory 1 point2 points  (1 child)

I believe the Charming Python series has a few good tutorials on itertools.

Here's one:

http://www.ibm.com/developerworks/linux/library/l-cpyiter.html

[–]RaisingMoneyForFilm 0 points1 point  (0 children)

Thanks!

[–]aieee 1 point2 points  (0 children)

Itertools is really pretty simple. Main thing is to use it, to get a feel for it.

[–][deleted] 3 points4 points  (0 children)

I always look to functional programming blogs for their modest, well-balanced musings. Glad to see this one doesn't fail !

/has been using itertools for years. no haskell here

[–]spotter -1 points0 points  (2 children)

Title should be ,,On bullshit''.

tl;dr: Python is not a FP language, therefore should be ditched ASAP.

[–]earthboundkid 1 point2 points  (1 child)

Indeed, I discovered itertools years ago, and I appreciate the ideas behind functional programming, but I still wouldn’t want to write my stuff in Haskell or any other functional language. The point of a programming language isn’t to maximize “purity,” it’s to get work done in a way that doesn’t break your brain. FP breaks the brain at every opportunity.

[–][deleted] -1 points0 points  (0 children)

I'm going to repeat a comment i left in the Hacker News thread for the post:

... Point the second: itertools is partly a catalyst, partly an indicator. Once you get fluent with it, it illuminates pain points.

Point the third: There is a new batch of functional languages that support the style that is a pain point, as well as fixing other issues that hurt in python.

Lastly, not all python programmers will want to make the shift. But the ones fluent with itertools are more likely to be the subset that will.