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). -- MarkJ Tacoma, Washington
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).
Perhaps a better suggestion is to call them an 'uninterpreted sequence of bits, presented to the user in 8-bit "chunks" (i.e. bytes).' -- MarkJ Tacoma, Washington
-----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-----
participants (2)
-
Georg Brandl
-
Mark Janssen