News for hackers. Stuff that matters.
Re:Unpythonic Python by kilink on Wednesday April 09, 2014 @02:38PM (#7561353)
A minor quibble, but in Python 3 you can print in a lambda because print is no longer a keyword.
Re:Unpythonic Python by gamegoblin on Wednesday April 09, 2014 @02:48PM (#7561429)
As a non-Python 3 user, I just opened up the python 3 REPL to try something I always find myself wanting to do in tiny little python scripts:

  map(print, some_list)
Unfortunately, it returned a map object, which I guess is also new in Python 3 (I assume it's a lazy application device).
Re:Unpythonic Python by benesch on Wednesday April 09, 2014 @03:01PM (#7561526)
You can (ab)use iterable unpacking in Py3k, now that print's a real function:

    print(*[1,2,3], sep='\n')
Re:Unpythonic Python by omaranto on Wednesday April 09, 2014 @11:46PM (#7564052)
I use this function to force evaluation of elements in a generator:

    def do(gen):
       for x in gen:
          pass
It evaluates all elements of a generator with storing them in memory. If you don't mind generating some garbage, you can just use the list function instead.
Re:Unpythonic Python by wting on Wednesday April 09, 2014 @03:14PM (#7561615)
Use `list()` to force eager evaluation with Python 3 map / filter.
Re:Unpythonic Python by kilink on Wednesday April 09, 2014 @02:51PM (#7561458)
Yeah, the map builtin is essentially itertools.imap in python 3.