[Python-ideas] Fixing the Python 3 bytes constructor
Nick Coghlan
ncoghlan at gmail.com
Fri Mar 28 12:00:44 CET 2014
On 28 March 2014 20:50, Steven D'Aprano <steve at pearwood.info> wrote:
>> 2. Add "bytearray.allnull" and "bytes.allnull" such that
>> "bytearray.allnull(x)" is equivalent to the current "bytearray(x)" int
>> handling
>
> +1 on bytearray.allnull, with a mild preference for spelling it "zeroes"
> instead.
If I could consistently remember whether to include the "e" or not,
"zeroes" would be my preference as well, but almost every time I go to
type it, I have to pause...
> I'm indifferent about bytes.allnull. I'm not sure why I would use it
> in preference to b'\0'*x, or for that matter why I would use it at all.
> I suppose if there's a bytearray.allnul, for symmetry there should be a
> bytes.allnul as well.
It's actually in the proposal solely because "bytes(x)" already works
that way, and "this is deprecated, use bytes.allnull instead" is a
much easier deprecation to sell.
>> Does the above proposal sound like a reasonable
>> suggestion for improvement in 3.5? Does this hit PEP territory, since
>> it's changing the signature and API of a builtin?
>
> On the vanishingly small chance that there is universal agreement on
> this, and a minimum of bike-shedding, I think it would still be useful
> to write up a brief half page PEP linking to the discussion here.
Yeah, that's make sense, so regardless of what happens in this thread,
I'll still be putting a PEP together and asking Guido for his verdict.
Heaps of time before 3.5 though...
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list