[TriPython] Thanks for coming out, plus a map()/reduce() followup

Philip Semanchuk philip at semanchuk.com
Fri Jun 29 08:21:35 EDT 2018


Hi all,
Thanks for coming out last night! The PDF on which my talk is based is linked from this blog post --
http://blog.pyspoken.com/2018/02/13/python-2-to-3-migration-guide/

I'll put some version of my slides online eventually, but probably not until after I give this talk at PyOhio in late July.

To the person who asked why "reduce" is in the category of "now" fixers while "map" is the "now, with review" category -- thanks for your interesting question. I looked it up, and the "reduce" fixer performs a trivial rename (reduce ==> functools.reduce()) whereas the "map" fixer wraps map() with list(). Like the dictionary methods we talked about last night (e.g. my_dict.keys()), in Python 2 map() returns a list but in Python 3 returns a generator, so wrapping it in a call to list() is safe but perhaps unnecessary which is why I recommend review. 

https://docs.python.org/2/library/2to3.html#2to3fixer-reduce
https://docs.python.org/2/library/2to3.html#2to3fixer-map

Cheers
Philip


More information about the TriZPUG mailing list