netutils-linux icon indicating copy to clipboard operation
netutils-linux copied to clipboard

from itertools import zip_longest in snmptop

Open strizhechenko opened this issue 8 years ago • 2 comments

https://twitter.com/mr_apt/status/886318871292121089

strizhechenko avatar Jul 15 '17 20:07 strizhechenko

x = [(1,2), (3,4)]
y = [(2,4), (6,8), (10,12)]
print(list(zip_longest(x, y, fillvalue=('', ''))))

strizhechenko avatar Jul 16 '17 03:07 strizhechenko

This is what I get when I run the code above

>>> x=[(1,2),(3,4)]
>>> y=[(2,4),(6,8),(10,12)]
>>> list(zip_longest(x,y, fillvalue=('','')))
[((1, 2), (2, 4)), ((3, 4), (6, 8)), (('', ''), (10, 12))]

It's different from the list[list] you want in your twitter message This is what your original code from the Twitter discussion gives

>>> somelist=[(1,2),(3,4),(5,6)]
>>> list(map(list, somelist))
[[1, 2], [3, 4], [5, 6]]

Winterflower avatar Sep 28 '17 08:09 Winterflower