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


Groups > comp.lang.python > #63745

Re: Python 3 __bytes__ method

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!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <meltingwax@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.06; 'suppose': 0.07; 'function,': 0.09; 'override': 0.09; 'subject:method': 0.09; '~ethan~': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'accepts': 0.16; 'subclass': 0.16; 'sat,': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'this?': 0.23; 'cc:2**0': 0.24; 'daniel': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'object.': 0.31; 'skip:r 60': 0.31; 'url:python': 0.33; "can't": 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'pm,': 0.38; 'url:mail': 0.40; 'read': 0.60; 'url:3': 0.61; 'guaranteed': 0.75; 'ethan': 0.84; 'furman': 0.84; 'url:datamodel': 0.84; 'url:reference': 0.84; 'logistics': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=JSGS5w2hzYXHgRQnW3rvqRJla41Vh/eFRWcLE/quM1w=; b=eXhnohGr4+q+9xO3CTK93k20bTdtUX0QZHM102QP+FHtltRW6iIy83RJ2aP0qDEQvH 9FUD8aa9ZgKcAq7YeXsB9A8kTdNNSr3q0OI055MwZxRMpI0IsyI+ZXUIFAGN33SbO9s9 cP+JizxLH6EpZU1KFkyZrMD60my44fc5CgZ8qkoY2CqmjnDhfZ/m4h1uQvySYpzWB4Ue x/rcO+01NKibAAi5VCxrNRneE3TWy9IE1RUSuZVnRkwyz804r0sXiGWTsEsVMOl9dlAj 9/igDG1XvHYVQ64rd7u97h7IHmOa/BAZXBZOixYINfgetZYdaZxTzdEnWgw+r0w/0zlq nAgQ==
MIME-Version 1.0
X-Received by 10.180.12.70 with SMTP id w6mr9319439wib.4.1389493141131; Sat, 11 Jan 2014 18:19:01 -0800 (PST)
Sender meltingwax@gmail.com
In-Reply-To <52D1E830.8070305@stoneleaf.us>
References <52D1E0CE.5030906@stoneleaf.us> <CACoeR0yZMGG8zsYKmF4MBjjeh3G-CUpYRbsBdNsufVNkjiap0g@mail.gmail.com> <52D1E830.8070305@stoneleaf.us>
Date Sat, 11 Jan 2014 21:19:01 -0500
X-Google-Sender-Auth xLqtQ1u2-8ux14jC4KdbSfLR0aY
Subject Re: Python 3 __bytes__ method
From Daniel da Silva <var.mail.daniel@gmail.com>
To Ethan Furman <ethan@stoneleaf.us>
Content-Type multipart/alternative; boundary=001a11c223ac18584504efbc95aa
X-Mailman-Approved-At Sun, 12 Jan 2014 04:07:24 +0100
Cc Python <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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5353.1389496044.18130.python-list@python.org> (permalink)
Lines 65
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389496045 news.xs4all.nl 2863 [2001:888:2000:d::a6]:43272
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63745

Show key headers only | View raw


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

One use case is:
Suppose you have existing function that accepts a *bytes* object. If you
subclass *bytes* and want it to be guaranteed to work with that function,
you can override* __bytes__()* to use the logistics of your subclass
implementation.


On Sat, Jan 11, 2014 at 7:56 PM, Ethan Furman <ethan@stoneleaf.us> wrote:

> On 01/11/2014 04:53 PM, Daniel da Silva wrote:
>
>>
>> Where did you read this? I can't find any documentation about __bytes__
>> on google.
>>
>
> http://docs.python.org/3.3/reference/datamodel.html?
> highlight=__bytes__#object.__bytes__
>
>
> --
> ~Ethan~
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


Thread

Re: Python 3 __bytes__ method Daniel da Silva <var.mail.daniel@gmail.com> - 2014-01-11 21:19 -0500

csiph-web