Python 3.x and bytes

Ethan Furman ethan at stoneleaf.us
Tue May 17 18:28:23 EDT 2011


Ian Kelly wrote:
> On Tue, May 17, 2011 at 2:20 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
>> The big question, though, is would you do it this way:
>>
>> some_var = bytes(23).replace(b'\x00', b'a')
>>
>> or this way?
>>
>> some_var = bytes(b'a' * 23)
> 
> Actually, I would just do it this way:
> 
> some_var = b'a' * 23
> 
> That's already a bytes object.  Passing it into the constructor is redundant.

Heh, good point.

~Ethan~



More information about the Python-list mailing list