Failing to import itertools in Python 3.5.2 -
i new python. trying import izip_longest itertools. not able find import "itertools" in preferences in python interpreter. using python 3.5.2. gives me below error-
from itertools import izip_longest importerror: cannot import name 'izip_longest'
please let me know right course of action. have tried python 2.7 , ended same problem. need use lower version python.
izip_longest
renamed zip_longest
in python 3 (note, no i
@ start), import instead:
from itertools import zip_longest
and use name in code.
if need write code works both on python 2 , 3, catch importerror
try other name, rename:
try: # python 3 itertools import zip_longest except importerror: # python 2 itertools import izip_longest zip_longest # use name zip_longest
Comments
Post a Comment