On Wed, Sep 4, 2019 at 12:43 AM Rhodri James <rho...@kynesim.co.uk> wrote:
>
> On 03/09/2019 15:27, Chris Angelico wrote:
> > On Tue, Sep 3, 2019 at 11:19 PM Rhodri James <rho...@kynesim.co.uk> wrote:
> >>
> >> On 03/09/2019 13:31, Chris Angelico wrote:
> >>> On Tue, Sep 3, 2019 at 10:27 PM Rhodri James <rho...@kynesim.co.uk> wrote:
> >>>>
> >>>> On 31/08/2019 12:31, Chris Angelico wrote:
> >>>>> We call it a string, but a bytes object has as much in common with
> >>>>> bytearray and with a list of integers as it does with a text string.
> >>>>
> >>>> You say that as if text strings aren't sequences of bytes.  Complicated
> >>>> and restricted sequences, I grant you, but no more so than a packet for
> >>>> a given network protocol.
> >>>>
> >>>
> >>> A text string is a sequence of characters. By "byte", I really mean
> >>> "octet", but Python prefers to say "byte".
> >>
> >> And a character is a byte or sequence of bytes. (Odd-sized bytes are
> >> pretty much history now, so for non-pendantic usages "byte" is good 
> >> enough.)
> >>
> >
> > But a character is not an octet.
>
> I get that you're distinguishing between the thing and its
> representation, but I'm coming at this as an embedded systems engineer.
> For me, it's turtles^Woctets all the way down.
>

Is an integer also a sequence of bytes? A float? A list? At some
level, everything's just stored as bytes in memory, but since there
are many possible representations of the same information, it's best
not to say that a character "is" a byte, but that it "can be stored
in" some number of bytes.

In Python, subscripting a text string gives you another text string.
Subscripting a list of integers gives you an integer. Subscripting a
bytearray gives you an integer. And (as of Python 3.0) subscripting a
bytestring also gives you an integer. Whether that's right or wrong
(maybe subscripting a bytestring should have been defined as yielding
a length-1 bytestring), subscripting a text string does not give an
integer, and subscripting a bytestring does not give a character.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/AQZX3HB7GZ7BLDOYVLEIVPEKO7MUOCWG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to