Re: [Python-ideas] Add a .chunks() method to sequences

2017-05-04 Thread Victor Stinner
2017-05-05 0:20 GMT+02:00 Greg Ewing : > While most uses would probably be for short strings, I can > think of uses cases involving large ones. For example, to > format a hex dump into lines with 8 bytes per line and spaces > between the lines: For such specialized use case, write a C extension.

Re: [Python-ideas] Add a .chunks() method to sequences

2017-05-04 Thread Greg Ewing
Victor Stinner wrote: I prefer str.join() approach: write a single chunks() function which takes a sequence, instead of modifying all sequence types around the world ;-) Even if a general sequence-chunking function is thought useful, it might be worth providing a special-purpose one as a string

Re: [Python-ideas] Add a .chunks() method to sequences

2017-05-04 Thread Victor Stinner
> 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 writ

Re: [Python-ideas] Storing a reference to the function object (if any) inside frame objects

2017-05-04 Thread Nick Coghlan
On 4 May 2017 at 18:59, Nathaniel Smith wrote: > Hi all, > > Currently, given a frame object (e.g. from sys._getframe or > inspect.getouterframes), there's no way to get back to the function > object that created it. This creates an obstacle for various sorts of > introspection. In particular, in

[Python-ideas] Storing a reference to the function object (if any) inside frame objects

2017-05-04 Thread Nathaniel Smith
Hi all, Currently, given a frame object (e.g. from sys._getframe or inspect.getouterframes), there's no way to get back to the function object that created it. This creates an obstacle for various sorts of introspection. In particular, in the unusual but real situation where you need to "mark" a f