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


Groups > comp.lang.python > #88181 > unrolled thread

Proposal for new minor syntax

Started byJamie Willis <jw14896.2014@my.bristol.ac.uk>
First post2015-03-27 20:24 +0000
Last post2015-03-28 20:13 -0700
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Proposal for new minor syntax Jamie Willis <jw14896.2014@my.bristol.ac.uk> - 2015-03-27 20:24 +0000
    Proposal for new minor syntax Sayth <flebber.crue@gmail.com> - 2015-03-28 20:13 -0700

#88181 — Proposal for new minor syntax

FromJamie Willis <jw14896.2014@my.bristol.ac.uk>
Date2015-03-27 20:24 +0000
SubjectProposal for new minor syntax
Message-ID<mailman.275.1427487867.10327.python-list@python.org>

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

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.

Another example could be when using Linked Lists, instead of writing
something like:

loop_node = loop_node.next

you could write:

loop_node .= next

Does this idea have any chance of acceptance if submitted as a PEP? What
are the potential concerns I could consider with the syntax?

Thanks,

Jamie

[toc] | [next] | [standalone]


#88243

FromSayth <flebber.crue@gmail.com>
Date2015-03-28 20:13 -0700
Message-ID<28edb3c6-e6ae-42c8-8b99-e3c172e262e5@googlegroups.com>
In reply to#88181
Sounds like you want to implement nim special dot syntax in python. 
http://nim-lang.org/manual.html#special-operators

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web