Hacker News new | past | comments | ask | show | jobs | submit login

I hope the new itertools.pairwise could be added to strings and lists with split()

e.g.

'abcdef'.split(2) == ['ab', 'cd', 'ef'] # not the same as .split("2")

[1, 2, 3, 4, 5, 6].split(3) == [[1,2,3], [4,5,6]]

Or one can use the `grouper` from the recipe

https://docs.python.org/3/library/itertools.html#itertools-r...




> 'abcdef'.split(2) == ['ab', 'cd', 'ef'] # not the same as .split("2")

Pairwise would give you ['ab', 'bc', 'cd', 'de', 'ef']. It's not a split.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: