[Python-ideas] Add a .chunks() method to sequences
Victor Stinner
victor.stinner at gmail.com
Thu May 4 12:50:36 EDT 2017
More information about the Python-ideas mailing list
Thu May 4 12:50:36 EDT 2017
- Previous message (by thread): [Python-ideas] Add a .chunks() method to sequences
- Next message (by thread): [Python-ideas] Add a .chunks() method to sequences
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> How about adding a chunks() and rchunks() function to sequences: > > [1,2,3,4,5,6,7].chunks(3) => [[1,2,3], [4,5,6], [7]] I prefer str.join() approach: write a single chunks() function which takes a sequence, instead of modifying all sequence types around the world ;-) It's less natural to write chunks(seq, n), but it's much simpler to implement and will work on all Python versions, enjoy! Victor
- Previous message (by thread): [Python-ideas] Add a .chunks() method to sequences
- Next message (by thread): [Python-ideas] Add a .chunks() method to sequences
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list