Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88184
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'programmer': 0.03; 'operator': 0.03; 'syntax': 0.04; 'that?': 0.05; 'acceptance': 0.09; 'statements': 0.09; 'python': 0.11; '"hello': 0.16; 'benefit.': 0.16; 'disallow': 0.16; 'in-place,': 0.16; 'minus': 0.16; 'of)': 0.16; 'right-hand': 0.16; 'side.': 0.16; 'syntactic': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'variable': 0.18; 'bit': 0.19; 'slightly': 0.19; 'written': 0.21; 'seems': 0.21; 'example': 0.22; 'propose': 0.24; "shouldn't": 0.24; 'sort': 0.25; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'room': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'operators': 0.31; 'piece': 0.31; 'allows': 0.31; 'class': 0.32; 'lists': 0.32; 'probably': 0.32; 'another': 0.32; 'entirely': 0.33; 'fri,': 0.33; 'could': 0.34; 'skip:s 30': 0.35; 'something': 0.35; 'anybody': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'belong': 0.36; 'doing': 0.36; 'next': 0.36; 'method': 0.36; 'similar': 0.36; 'example,': 0.37; 'list': 0.37; 'subject:new': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'realize': 0.39; 'to:addr:python.org': 0.39; 'helps': 0.61; 'new': 0.61; 'save': 0.62; 'field': 0.63; 'provide': 0.64; 'more': 0.64; 'chance': 0.65; 'linked': 0.65; 'world': 0.66; 'side': 0.67; 'mar': 0.68; 'beat': 0.68; 'special': 0.74; 'hand': 0.80; 'as:': 0.81; '2015': 0.84; 'legal?': 0.84; 'short,': 0.84; 'subject:Proposal': 0.91; 'write:': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=yTV+V0gZ9uw8kT/05oeyPf+oiQuApCJHVRBjY0KYe6I=; b=dpkzkCRLUOetEJAJEzfHyLDDTaxns2cM7RE3GOWsrD87yPoG29uyI3usRZGDj9u9h2 WBdNOqmUVYGmPQ/byxNsGs39rXEJPFutojtBPG6+s/Me0jJvxp8TWi+b8MRKDrupXR4D /1rij+9dig1gzuNjm2G5M+ompKdoy+3gy/Dt4sWKOm8+NBQB0ho4lMaHsLkmbOakvlYd 31vadwlzqJZ3o4j0tyCswx3sOrEf48cwsmP7nNDJIMgTfEUYDc45wCGVn40+KLi0FqQa CPkWB0Hl2ZGJdE8YKm1Bx8HIi8d9X+fh4p1/SfJQNtkdkWh0r5RNtqwz8gxbVI8Qay99 ALqg== |
| X-Received | by 10.66.178.139 with SMTP id cy11mr36969358pac.146.1427489327234; Fri, 27 Mar 2015 13:48:47 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <CAPauRLMMAT-OffHTYW6GPybAZzouc7H9BjrmvVQiSig0X3x+ig@mail.gmail.com> |
| References | <CAPauRLMMAT-OffHTYW6GPybAZzouc7H9BjrmvVQiSig0X3x+ig@mail.gmail.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Fri, 27 Mar 2015 14:48:06 -0600 |
| Subject | Re: Proposal for new minor syntax |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.19 |
| 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.278.1427489337.10327.python-list@python.org> (permalink) |
| Lines | 54 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1427489337 news.xs4all.nl 2870 [2001:888:2000:d::a6]:49914 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:88184 |
Show key headers only | View raw
On Fri, Mar 27, 2015 at 2:24 PM, Jamie Willis
<jw14896.2014@my.bristol.ac.uk> wrote:
> I would like to propose a new piece of syntax for the python language; .=
>
> In short, the operator is form of syntactic sugar, for instance consider the
> following code:
>
> hello = "hello world "
> hello = hello.strip()
>
> This could be written as:
>
> hello = "hello world "
> hello .= strip()
>
> In this slightly contrived example, the programmer saved (a small amount of)
> time when writing the code. With code with longer variable names, or lots of
> similar statements all in a row, this helps to keep code more concise.
>
> The operator would be constricted to one method or field on the right-hand
> side, which must belong to the object on the left hand side.
Do you mean that this would not be legal?
hello .= strip().upper().encode('utf-8')
Is there a reason you want to disallow that?
> Another example could be when using Linked Lists, instead of writing
> something like:
>
> loop_node = loop_node.next
>
> you could write:
>
> loop_node .= next
I realize this is just an example, but does anybody actually use
linked lists in Python outside of class assignments? It seems hard to
justify performance-wise since list is written in C, and if you need
to beat it, then you probably shouldn't be doing so in Python.
> Does this idea have any chance of acceptance if submitted as a PEP? What are
> the potential concerns I could consider with the syntax?
On the plus side it doesn't add any new keywords or conflict with any
existing syntax.
On the minus side it seems marginal in utility to me, as all it does
is save a bit of typing. The +=, etc. operators are backed by special
methods named __iadd__ etc. which allows the class author to provide
for the operation to be performed in-place, or to change the meaning
entirely use the operator as part of a DSL. This proposal doesn't have
any room that I can see for that sort of benefit.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Proposal for new minor syntax Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-27 14:48 -0600
Re: Proposal for new minor syntax BartC <bc@freeuk.com> - 2015-03-27 23:08 +0000
Re: Proposal for new minor syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-28 20:53 +1100
Re: Proposal for new minor syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-28 21:43 +1100
Re: Proposal for new minor syntax Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2015-04-09 09:32 +0200
Re: Proposal for new minor syntax BartC <bc@freeuk.com> - 2015-03-28 13:38 +0000
Re: Proposal for new minor syntax Mario Figueiredo <marfig@gmail.com> - 2015-03-28 16:05 +0100
Re: Proposal for new minor syntax Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-28 22:15 -0600
Re: Proposal for new minor syntax Rustom Mody <rustompmody@gmail.com> - 2015-03-28 21:50 -0700
Re: Proposal for new minor syntax Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-28 21:01 +1100
csiph-web