On Mon, Nov 8, 2021 at 8:21 PM Ethan Furman wrote:
> The difference with the built-in ascii is the absence of extra quotes and the
> `b` indicator when a string is used:
>
> ```
> >>> u_var = u'abc'
> >>> bytes.ascii(u_var)
> b'abc'
What about bytes, bytearray and memoryview? What is the
On 11/8/21 4:45 AM, Victor Stinner wrote:
> Is it implement "like" ascii(obj).encode("ascii") but with minor
> changes? What changes?
It works like `str()`, but you get ascii-encoded bytes (or an exception if
that's not possible).
The difference with the built-in ascii is the absence of extra
The ascii() constructor is not well specified by the PEP. There are
only a few examples. I don't understand how it's supposed by be
implemented. Would you mind to elaborate its specification?
Is it implement "like" ascii(obj).encode("ascii") but with minor
changes? What changes?
Victor
On Fri, Nov 5, 2021 at 2:59 AM Jonathan Goble wrote:
>
> On Thu, Nov 4, 2021 at 10:37 AM Eric Fahlgren wrote:
>>
>> On Thu, Nov 4, 2021 at 12:01 AM Ethan Furman wrote:
>>>
>>> >>> bytearray.fromsize(5, fill=b'\x0a')
>>> bytearray(b'\x0a\x0a\x0a\x0a\x0a')
>>
>>
>> What happens if you
On Thu, Nov 4, 2021 at 10:37 AM Eric Fahlgren
wrote:
> On Thu, Nov 4, 2021 at 12:01 AM Ethan Furman wrote:
>
>> >>> bytearray.fromsize(5, fill=b'\x0a')
>> bytearray(b'\x0a\x0a\x0a\x0a\x0a')
>>
>
> What happens if you supply more than one byte for the fill argument?
> Silent
On Thu, Nov 4, 2021 at 12:01 AM Ethan Furman wrote:
> >>> bytearray.fromsize(5, fill=b'\x0a')
> bytearray(b'\x0a\x0a\x0a\x0a\x0a')
>
What happens if you supply more than one byte for the fill argument?
Silent truncation, raise ValueError('too long') or ???