add discouraged use example
This commit is contained in:
parent
9f5ceed90a
commit
68f8127d26
|
@ -56,10 +56,12 @@ Proposals
|
|||
Addition of explicit "count and byte initialised sequence" constructors
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
To replace the now discouraged behavior, this PEP proposes the addition of an
|
||||
explicit ``fromsize`` alternative constructor as a class method on both
|
||||
``bytes`` and ``bytearray`` whose first argument is the count, and whose
|
||||
second argument is the fill byte to use (defaults to ``\x00``)::
|
||||
To replace the discouraged behavior of creating zero-filled ``bytes``-like
|
||||
objects from the basic constructors (i.e. ``bytes(1)`` --> ``b'\x00'``), this
|
||||
PEP proposes the addition of an explicit ``fromsize`` alternative constructor
|
||||
as a class method on both ``bytes`` and ``bytearray`` whose first argument
|
||||
is the count, and whose second argument is the fill byte to use (defaults
|
||||
to ``\x00``)::
|
||||
|
||||
>>> bytes.fromsize(3)
|
||||
b'\x00\x00\x00'
|
||||
|
|
Loading…
Reference in New Issue