[docs] bytearray and language usage.
Georg Brandl
georg at python.org
Sun Oct 6 11:27:50 CEST 2013
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Am 28.06.2013 01:50, schrieb Mark Janssen:
> Looking at the Python docs for v2.7.5.
>
> Section 2.
>
> bytearray([source[, encoding[, errors]]])
>
> " Return a new array of bytes. The bytearray type is a mutable sequence of
> integers in the range 0 <= x < 256."
>
> This should not be called a "mutable sequence of integers", because to call
> them "integers" already casts raw bits into a particular *type*. They
> could, hypothetically be very short floats, for example.
>
> More accurately, they are merely "uninterpreted bits presented to the user
> in 8-bit chunks, with a consistent starting boundary" (held by the machine
> storage address).
Hi Mark,
the language is actually correct; Python treats bytearrays as sequences
of integers. Try this:
>>> list(bytearray(b"abc"))
[97, 98, 99]
cheers,
Georg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (GNU/Linux)
iEYEARECAAYFAlJRLRYACgkQN9GcIYhpnLCDIACfSAgx4jI0ye8o6Dk+Tc1KbPPl
8VcAn0vSiK4JkaIU49HLu6t7K0kTj9po
=sKwd
-----END PGP SIGNATURE-----
More information about the docs
mailing list