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


Groups > comp.lang.python > #63743

Re: Python 3 __bytes__ method

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ethan@stoneleaf.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.06; 'suppose': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'function,': 0.09; 'message-id:@stoneleaf.us': 0.09; 'method,': 0.09; 'subject:method': 0.09; '~ethan~': 0.09; 'accepts': 0.16; 'expecting': 0.16; 'received:gateway01.websitewelcome.com': 0.16; 'subclass': 0.16; 'unlikely': 0.16; 'wrote:': 0.18; 'header:User- Agent:1': 0.23; 'bytes': 0.24; 'daniel': 0.26; 'header:In-Reply- To:1': 0.27; 'function': 0.29; 'object.': 0.31; 'objects': 0.35; 'object,': 0.36; 'so,': 0.37; 'two': 0.37; 'skip:o 20': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:173': 0.61; 'guaranteed': 0.75; 'logistics': 0.95
Date Sat, 11 Jan 2014 18:44:55 -0800
From Ethan Furman <ethan@stoneleaf.us>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
MIME-Version 1.0
To Python <python-list@python.org>
Subject Re: Python 3 __bytes__ method
References <52D1E0CE.5030906@stoneleaf.us> <CACoeR0yZMGG8zsYKmF4MBjjeh3G-CUpYRbsBdNsufVNkjiap0g@mail.gmail.com> <52D1E830.8070305@stoneleaf.us> <CACoeR0zm6LMAVnoh4y1_pna9rc3+P_cL_u=2FavBz0DL42ehnA@mail.gmail.com>
In-Reply-To <CACoeR0zm6LMAVnoh4y1_pna9rc3+P_cL_u=2FavBz0DL42ehnA@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - gator3304.hostgator.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - stoneleaf.us
X-BWhitelist no
X-Source-IP 173.12.184.233
X-Source
X-Source-Args
X-Source-Dir
X-Source-Sender ([173.12.184.233]) [173.12.184.233]:53353
X-Source-Auth ethan+stoneleaf.us
X-Email-Count 1
X-Source-Cap dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20=
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.5352.1389494690.18130.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389494690 news.xs4all.nl 2885 [2001:888:2000:d::a6]:38345
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63743

Show key headers only | View raw


On 01/11/2014 06:19 PM, Daniel da Silva wrote:
>
> 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.

I don't think so, for two reasons:

1) bytes objects do not have a __bytes__ method,

2) if the function is expecting a bytes object, it is unlikely to call bytes() on it.

--
~Ethan~

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


Thread

Re: Python 3 __bytes__ method Ethan Furman <ethan@stoneleaf.us> - 2014-01-11 18:44 -0800

csiph-web