Hacker News new | past | comments | ask | show | jobs | submit login

Peter, we need to talk.

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

"combinations()" is a built in. No need to re-implement it. Also, nested [... for ... for ... for] is silly. Just use "product()", documented on the same page.

[''.join(card) for card in product('123', 'RGP', '@O=', 'OSD')]

They say that six months after learning the itertools module, people give up on Python for Lisp. Which would be hilarious, in your case.




I've asked him about this, here is his reply:

"[...] about itertools -- I guess I got the impression that itertools is deprecated in 3.0, or at least that Guido doesn't much like it, so I have stayed away from it. And itertools.combinations is only in 2.6, so I think I will leave things as is, for those still stuck in 2.5."


Combinations is also in +3.0. Otherwise a valid concern. (Been burned by that one myself.)

I can't find the source, but there might be some confusion between map/filter/reduce and itertools. Guido does not like map/filter/reduce and wants to get rid of them.

Itertools is a huge part of Python 3.0. Everything is an iterator in the language. And the docs underwent a major rewrite with the 3.0 release. It is not going to be deprecated.


It's entirely possible he wrote this before itertools existed. Like in the IAQ where he says things like:

"Better to stick with x += 1, which was added in Python 2.0. "

( http://norvig.com/python-iaq.html )




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: