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


Groups > comp.lang.python > #67000

Python 3.5, bytes, and %-interpolation (aka PEP 461)

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'subject:PEP': 0.07; 'accepted,': 0.09; 'ascii': 0.09; 'assuming': 0.09; 'encode': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'pep': 0.09; '~ethan~': 0.09; 'python': 0.11; 'repr': 0.16; 'discussion': 0.18; 'header:User- Agent:1': 0.23; 'bytes': 0.24; 'skip:% 10': 0.24; '(or': 0.24; 'points': 0.29; 'code': 0.31; 'subject:skip:i 10': 0.31; 'anybody': 0.35; 'convert': 0.35; 'add': 0.35; 'should': 0.36; 'handle': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:173': 0.61; 'back': 0.62; 'debate': 0.68; 'greetings!': 0.84; 'do:': 0.91
Date Mon, 24 Feb 2014 11:54:54 -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 Python 3.5, bytes, and %-interpolation (aka PEP 461)
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]:49441
X-Source-Auth ethan+stoneleaf.us
X-Email-Count 3
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.7328.1393271688.18130.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1393271688 news.xs4all.nl 2967 [2001:888:2000:d::a6]:56276
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:67000

Show key headers only | View raw


Greetings!

A PEP is under discussion to add %-interpolation back to the bytes type in Python 3.5.

Assuming the PEP is accepted, what *will* be added back is:

Numerics:

   b'%d' % 10  --> b'10'
   b'%02x' % 10  --> b'0a'

Single byte:

   b'%c' % 80  --> b'P'

and generic:

   b'%s' % some_binary_blob --> b'tHE*&92h4' (or whatever)

What is under debate is whether we should also add %a:

   b'%a' % some_obj  --> b'some_obj_repr'

What %a would do:

   get the repr of some_obj

   convert it to ascii using backslashreplace (to handle any code points over 127)

   encode to bytes using 'ascii'

Can anybody think of a use-case for this particular feature?

--
~Ethan~

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


Thread

Python 3.5, bytes, and %-interpolation  (aka PEP 461) Ethan Furman <ethan@stoneleaf.us> - 2014-02-24 11:54 -0800
  Re: Python 3.5, bytes, and %-interpolation  (aka PEP 461) Marko Rauhamaa <marko@pacujo.net> - 2014-02-24 22:46 +0200
    Re: Python 3.5, bytes, and %-interpolation  (aka PEP 461) random832@fastmail.us - 2014-02-24 16:04 -0500
      Re: Python 3.5, bytes, and %-interpolation  (aka PEP 461) Marko Rauhamaa <marko@pacujo.net> - 2014-02-25 00:18 +0200
        Re: Python 3.5, bytes, and %-interpolation  (aka PEP 461) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-24 23:55 +0000
          Re: Python 3.5, bytes, and %-interpolation  (aka PEP 461) wxjmfauth@gmail.com - 2014-02-25 00:07 -0800
            Re: Python 3.5, bytes, and %-interpolation  (aka PEP 461) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-02-25 08:29 +0000
    Re: Python 3.5, bytes, and %-interpolation  (aka PEP 461) Ethan Furman <ethan@stoneleaf.us> - 2014-02-24 13:53 -0800
  Re: Python 3.5, bytes, and %-interpolation  (aka PEP 461) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-24 23:55 +0000
    Re: Python 3.5, bytes, and %-interpolation  (aka PEP 461) Ethan Furman <ethan@stoneleaf.us> - 2014-02-24 16:10 -0800
      Re: Python 3.5, bytes, and %-interpolation  (aka PEP 461) Steven D'Aprano <steve@pearwood.info> - 2014-02-25 07:29 +0000

csiph-web