Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #47579

Re: Encoding questions (continuation)

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <fabiosantosart@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'charset:iso-8859-7': 0.04; 'binary': 0.07; 'indexing': 0.07; 'string': 0.09; 'integers': 0.09; 'objects,': 0.09; 'system?': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'stored': 0.12; 'andreas': 0.16; 'bye': 0.16; 'byte,': 0.16; 'character.': 0.16; 'declared': 0.16; 'digits.': 0.16; 'heed': 0.16; 'integers,': 0.16; 's[0]': 0.16; 'subject:questions': 0.16; 'zeros': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'byte': 0.24; 'bytes': 0.24; 'integer': 0.24; 'string,': 0.24; 'mon,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 0.26; 'asking': 0.27; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'too.': 0.31; '255,': 0.31; "d'aprano": 0.31; 'decimal': 0.31; 'index,': 0.31; 'steven': 0.31; 'not.': 0.33; 'subject: (': 0.35; 'basic': 0.35; 'advice': 0.35; 'no,': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'object,': 0.36; 'ones,': 0.36; 'sequence': 0.36; 'yield': 0.36; 'doing': 0.36; 'similar': 0.36; 'should': 0.36; 'list': 0.37; 'skip:& 10': 0.38; 'does': 0.39; 'how': 0.40; 'read': 0.60; 'number,': 0.60; 'numbers': 0.61; 'course': 0.61; 'first': 0.61; 'deals': 0.65; 'to:addr:gmail.com': 0.65; 'series': 0.66; 'between': 0.67; 'yes': 0.68; '8bit%:57': 0.74; 'computing.': 0.84; 'treating': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=akJrqTOtM0vsQvqxS7z28YE9rk1Q9V6Z0WxgdVZAxyI=; b=MrZYYNbmli9s55ieIs9vitO5EJpqKseSggdW8M22hiEvF/czuc3qaP7XzXqkQYy+az gfIFllNCSSkJQ2UWBoadj0v/vevUHy5I6/LLAkuyXkZyK+Jdo2u4qWJj6ZRpjuJMT8g0 8WJjHFyIWwi5RkwuOxRLFBhAi7QeayuS3XTdQFmHv0Q858PHT6tpXI0bsCi6Dm9/Vi8O l7PpXoqiZ8CFiLoivErpE0EqQ65c/tN/r9NjCIQXsUILkJogbLXcwGNCC4fIp0O7OVzV lrHs/4VBj0p5DxKcDravMRKq4obImSbxkEw0e0Fcmjfmws3LVerB+ShifowzKGsQDdoA Z23Q==
MIME-Version 1.0
X-Received by 10.229.170.131 with SMTP id d3mr4186560qcz.92.1370881032840; Mon, 10 Jun 2013 09:17:12 -0700 (PDT)
In-Reply-To <71d585e6-bb98-47b7-9a45-7cde1ba0c48f@googlegroups.com>
References <mailman.2964.1370862786.3114.python-list@python.org> <51b5bb53$0$29997$c3e8da3$5496439d@news.astraweb.com> <71d585e6-bb98-47b7-9a45-7cde1ba0c48f@googlegroups.com>
Date Mon, 10 Jun 2013 17:17:12 +0100
Subject Re: Encoding questions (continuation)
From Fábio Santos <fabiosantosart@gmail.com>
To Νικόλαος Κούρας <nikos.gr33k@gmail.com>
Content-Type multipart/alternative; boundary=14dae9c09c1efe09de04decf1c6e
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2973.1370882588.3114.python-list@python.org> (permalink)
Lines 192
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1370882588 news.xs4all.nl 15892 [2001:888:2000:d::a6]:34507
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:47579

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 10 Jun 2013 15:04, "Νικόλαος Κούρας" <nikos.gr33k@gmail.com> wrote:
>
> Τη Δευτέρα, 10 Ιουνίου 2013 2:41:07 μ.μ. UTC+3, ο χρήστης Steven D'Aprano
έγραψε:
> > On Mon, 10 Jun 2013 14:13:00 +0300, Νικόλαος Κούρας wrote:
> >
> >
> >
> > > Τη Δευτέρα, 10 Ιουνίου 2013 1:42:25 μ.μ. UTC+3, ο χρήστης Andreas
> >
> > > Perstinger έγραψε:
> >
> > >
> >
> > >  >  >>> s = b'\xce\xb1'
> >
> > >  >
> >
> > >  >  >>> s[0]
> >
> > >  >
> >
> > >  > 206
> >
> > >
> >
> > > 's' is a byte object, how can you treat it as a string asking to
present
> >
> > > you its first character?
> >
> >
> >
> > That is not treating it as a string, and it does not present the first
> >
> > character. It presents the first byte, which is a number between 0 and
> >
> > 255, not a character.
> >
> >
> >
> > py> alist = [0xce, 0xb1]
> >
> > py> alist[0]
> >
> > 206
>
>
> To my mind alist[0] should yield '0xce'

This happens because 0xce is an integer object too. Integer objects have no
"memory" of what format they were declared on. Oxce just happens to be 206
in hexadecimal. Ob10 would also result in the integer 2.

> > Is that treating alist as a string? No, of course not. Strings are not
> >
> > the only object that have indexing object[position].
>
> Yes actually it does.
>
> s string is a series of characters.
>
> a list is a series of objects, which can be chars, strings, integers,
other data structures.
>
> So doing a_list[0] is similar of doing a_string[00
>
>
> > >  > A byte object is a sequence of bytes (= integer values) and support
> > > indexing
>
>
> Isn't a byte a series of zeros and ones, like 01010101 ?
> So why you say bytes are integers since its numbers into a binary system?
> perhsp you mean a represantaion of a bye to a decimal value?

A byte is a number, stored in (usually) 8 binary digits. By addressing a
bytes object by its index, you get an integer of that byte. That's just how
python deals with it.

You should heed Steven's advice and read up on basic computing. You seem to
be lacking a lot of basic concepts.

Cheers.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Encoding questions (continuation) Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-10 14:13 +0300
  Re: Encoding questions (continuation) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-10 11:41 +0000
    Re: Encoding questions (continuation) Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-10 06:56 -0700
      Re: Encoding questions (continuation) Fábio Santos <fabiosantosart@gmail.com> - 2013-06-10 17:17 +0100
      Re: Encoding questions (continuation) Larry Hudson <orgnut@yahoo.com> - 2013-06-11 00:52 -0700
        Re: Encoding questions (continuation) Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-11 13:09 -0700
          Re: Encoding questions (continuation) Larry Hudson <orgnut@yahoo.com> - 2013-06-12 01:20 -0700
            Re: Encoding questions (continuation) Larry Hudson <orgnut@yahoo.com> - 2013-06-12 01:32 -0700
      OT: e-mail reply to old/archived message (was Re: Encoding questions (continuation)) Andreas Perstinger <andipersti@gmail.com> - 2013-06-11 13:21 +0200
        Re: OT: e-mail reply to old/archived message (was Re: Encoding questions (continuation)) Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-11 13:14 -0700
          Re: OT: e-mail reply to old/archived message Andreas Perstinger <andipersti@gmail.com> - 2013-06-12 00:13 +0200
            Re: OT: e-mail reply to old/archived message nagia.retsina@gmail.com - 2013-06-11 18:16 -0700
              Re: OT: e-mail reply to old/archived message Phil Connell <pconnell@gmail.com> - 2013-06-12 07:36 +0100
                Re: OT: e-mail reply to old/archived message nagia.retsina@gmail.com - 2013-06-11 23:58 -0700
    Re: Encoding questions (continuation) Lele Gaifax <lele@metapensiero.it> - 2013-06-11 00:19 +0200
      Re: Encoding questions (continuation) Νικόλαος Κούρας <nikos.gr33k@gmail.com> - 2013-06-11 13:06 -0700

csiph-web