Neat way to port nonpolyglot code from Py2 to Py3

前端 未结 3 2054
抹茶落季
抹茶落季 2021-01-22 10:28

In many of my python modules, I am using

from itertools import izip_longest

But now I am moving my codebase to Py3 (compatible with Py2 at the sa

3条回答
  •  隐瞒了意图╮
    2021-01-22 10:44

    You can wrap that exact code inside a module of your own, say itertools_compat.py, and just write

    from itertools_compat import izip_longest
    

    wherever you need this function.

提交回复
热议问题