On 04/05/17 01:24, Steven D'Aprano wrote:
On Thu, May 04, 2017 at 12:13:25AM +0100, Erik wrote:
I had a use-case where splitting an iterable into a sequence of
same-sized chunks efficiently improved the performance of my code
[...]
So I didn't propose it. I have no idea now what I spent my
On Thu, May 04, 2017 at 12:13:25AM +0100, Erik wrote:
> I had a use-case where splitting an iterable into a sequence of
> same-sized chunks efficiently improved the performance of my code
[...]
> So I didn't propose it. I have no idea now what I spent my saved hours
> doing, but I imagine that
Hi Paul,
On 03/05/17 08:57, Paul Moore wrote:
> On 3 May 2017 at 02:48, Erik wrote:
>> Anyway, I know you can't stop anyone from *proposing* something like
this,
>> but as soon as they do you may decide to quote the recipe from
>>
On 3 May 2017 at 08:10, Greg Ewing wrote:
> For a name, I think "group" would be better than "chunk".
> We talk about grouping the digits of a number, not chunking
> them.
As soon as I added an intermediate variable to my example, I came to
the same conclusion:
On Wed, May 03, 2017 at 02:48:03AM +0100, Erik wrote:
> On 03/05/17 01:43, Steven D'Aprano wrote:
> >I'm not stopping anyone from proposing a generalisation of this that
> >works with other sequence types. As somebody did :-)
>
> Who? I didn't spot that in the thread - please give a reference.
On Tue, May 02, 2017 at 09:07:41PM -0400, Juancarlo Añez wrote:
> On Tue, May 2, 2017 at 8:43 PM, Steven D'Aprano wrote:
>
> > String methods should return strings.
> >
>
> >>> "A-B-C".split("-")
> ['A', 'B', 'C']
Yes, thank you. And don't forget:
py> 'abcd'.index('c')
2
On 3 May 2017 at 02:48, Erik wrote:
> Anyway, I know you can't stop anyone from *proposing* something like this,
> but as soon as they do you may decide to quote the recipe from
> "https://docs.python.org/3/library/functions.html#zip; and try to block
> their
Steven D'Aprano wrote:
I've also been thinking about generalisations such as grouping lines
into paragraphs, words into lines, etc.
You're probably going to want considerably more complicated
algorithms for that kind of thing, though. Let's keep it
simple.
--
Greg
On Tue, May 2, 2017 at 8:43 PM, Steven D'Aprano wrote:
> String methods should return strings.
>
>>> "A-B-C".split("-")
['A', 'B', 'C']
If chunk() worked for all iterables:
>>> " ".join("1234ABCDEF".chunk(4))
"1234 ABCD EF"
Cheers,
--
Juancarlo *Añez*
On Tue, May 02, 2017 at 11:39:48PM +0100, Erik wrote:
> On 02/05/17 12:31, Steven D'Aprano wrote:
> >Rather than duplicate the API and logic everywhere, I suggest we add a
> >new string method. My suggestion is str.chunk(size, delimiter=' ') and
> >str.rchunk() with the same arguments:
For the
On Tue, May 02, 2017 at 10:48:08AM -0700, David Mertz wrote:
> Maybe your API is for any length tuple, with the final element repeated.
> So I guess maybe this example could be:
>
> "0113225551212".rchunk((2,2,3,1,2,3),'-')
That's what I meant.
--
Steve
On 02/05/17 12:31, Steven D'Aprano wrote:
I disagree with this approach. There's nothing special about bytes.hex()
here, perhaps we want to format the output of hex() or bin() or oct(),
or for that matter "%x" and any of the other string templates?
In fact, this is a string operation that could
For a name, I think "group" would be better than "chunk".
We talk about grouping the digits of a number, not chunking
them.
--
Greg
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of
The main reason for naming it `delimit` was to be consistent with the karg
`delimiter`, so `str.delimit(index, delimiter)`. You could call it `chop` I
guess, but I'm just bikeshedding, so will leave it while you guys figure
out the important stuff.
-- Carl Smith
carl.in...@gmail.com
On 2 May
On Tue, May 2, 2017 at 4:31 AM, Steven D'Aprano wrote:
> Rather than duplicate the API and logic everywhere, I suggest we add a
> new string method. My suggestion is str.chunk(size, delimiter=' ') and
> str.rchunk() with the same arguments:
>
> "1234ABCDEF".chunk(4)
> =>
On Tue, May 02, 2017 at 11:45:35PM +1000, Nick Coghlan wrote:
> Attempting to align the terminology with existing string methods and
> other stdlib APIs:
[...]
> 1. we don't have any current APIs or documentation that use "chunk" in
> combination with any kind of delimiter
> 2. we don't have any
On 2 May 2017 at 21:31, Steven D'Aprano wrote:
> On Mon, May 01, 2017 at 11:38:20PM +1000, Nick Coghlan wrote:
>> However, a much simpler alternative would be to just support two
>> keyword arguments to hex(): "delimiter" (as you suggest) and
>> "chunk_size" (defaulting to 1,
On the block size arg, couldn't it just be named `index`?
On Tue, 2 May 2017 13:12 Carl Smith, wrote:
> Sorry. I meant to be terse, but wasn't clear enough. I meant the method
> name. If it takes a `delimiter` karg, it would be consistent to call the
> operation `delimit`.
Sorry. I meant to be terse, but wasn't clear enough. I meant the method
name. If it takes a `delimiter` karg, it would be consistent to call the
operation `delimit`.
On Tue, 2 May 2017 13:06 Carl Smith, wrote:
> Couldn't it just be named `str.delimit`? I totally agree with
Couldn't it just be named `str.delimit`? I totally agree with Steve for
what it's worth. Thanks for everything guys. Best,
On Tue, 2 May 2017 13:02 Joao S. O. Bueno, wrote:
> On 1 May 2017 at 11:04, Juancarlo Añez wrote:
> >
> > On Mon, May 1, 2017 at
On 1 May 2017 at 11:04, Juancarlo Añez wrote:
>
> On Mon, May 1, 2017 at 9:38 AM, Nick Coghlan wrote:
>>
>> just support two
>> keyword arguments to hex(): "delimiter" (as you suggest) and
>> "chunk_size" (defaulting to 1, so you get per-byte chunking by
>>
On Mon, May 01, 2017 at 11:38:20PM +1000, Nick Coghlan wrote:
> We're definitely open to offering better formatting options for bytes.hex().
>
> My proposal in https://bugs.python.org/issue22385 was to define a new
> formatting mini-language (akin to the way strftime works, but with a
> much
On 5/1/2017 1:41 PM, Alexandre Brault wrote:
On 2017-05-01 01:34 PM, Ethan Furman wrote:
On 05/01/2017 07:04 AM, Juancarlo Añez wrote:
On Mon, May 1, 2017 at 9:38 AM, Nick Coghlan wrote:
just support two
keyword arguments to hex(): "delimiter" (as you suggest) and
"chunk_size" (defaulting to
On 2017-05-01 01:41 PM, Alexandre Brault wrote:
> On 2017-05-01 01:34 PM, Ethan Furman wrote:
>> On 05/01/2017 07:04 AM, Juancarlo Añez wrote:
>>> On Mon, May 1, 2017 at 9:38 AM, Nick Coghlan wrote:
>>>
just support two
keyword arguments to hex(): "delimiter" (as you suggest) and
On 2017-05-01 01:34 PM, Ethan Furman wrote:
> On 05/01/2017 07:04 AM, Juancarlo Añez wrote:
>> On Mon, May 1, 2017 at 9:38 AM, Nick Coghlan wrote:
>>
>>> just support two
>>> keyword arguments to hex(): "delimiter" (as you suggest) and
>>> "chunk_size" (defaulting to 1, so you get per-byte
On 05/01/2017 07:04 AM, Juancarlo Añez wrote:
On Mon, May 1, 2017 at 9:38 AM, Nick Coghlan wrote:
just support two
keyword arguments to hex(): "delimiter" (as you suggest) and
"chunk_size" (defaulting to 1, so you get per-byte chunking by
default)
I'd expect "chunk_size" to mean the number
On 1 May 2017 at 17:19, wrote:
> The bytes.hex() function is the inverse function of Bytes.fromhex().
>
> But fromhex can process spaces (which is much more readable), while hex()
> provides no way to include spaces.
>
> My proposal would be to add an optional delimiter,
The bytes.hex() function is the inverse function of Bytes.fromhex().
But fromhex can process spaces (which is much more readable), while hex()
provides no way to include spaces.
My proposal would be to add an optional delimiter, that allows to specify a
string that will be inserted between the
28 matches
Mail list logo