netutils-linux
netutils-linux copied to clipboard
from itertools import zip_longest in snmptop
https://twitter.com/mr_apt/status/886318871292121089
x = [(1,2), (3,4)]
y = [(2,4), (6,8), (10,12)]
print(list(zip_longest(x, y, fillvalue=('', ''))))
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]]