[Python-ideas] Fixing the Python 3 bytes constructor

Alexander Belopolsky alexander.belopolsky at gmail.com
Fri Mar 28 16:28:39 CET 2014


On Fri, Mar 28, 2014 at 9:41 AM, Ron Adam <ron3200 at gmail.com> wrote:

> >>> y = np.zeros((2, 3, 4))
> >>> y.shape
> (2, 3, 4)
>
> (Without the e.)  I'm not sure if it's a good idea to use zeros with a
> different signature.
>

np.zeros() can be called with an integer (length) argument as well:

>>> np.zeros(3)
array([ 0.,  0.,  0.])

To be completely analogous to the proposed bytes constructor, you would
have to specify the data type, though:

>>> np.zeros(3, 'B')
array([0, 0, 0], dtype=uint8)

+1 for bytes.zeros(n)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140328/7d23c9e3/attachment.html>


More information about the Python-ideas mailing list