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


Groups > comp.lang.python > #90827

Re: Rule of order for dot operators?

X-FeedAbuse http://nntpfeed.proxad.net/abuse.pl feeded by 78.192.65.63
Path csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!news.muarf.org!news.roellig-ltd.de!open-news-network.org!border2.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
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; 'operator': 0.03; 'syntax': 0.04; 'element': 0.07; 'nested': 0.07; 'operator,': 0.09; 'ron': 0.09; 'uses.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; "wouldn't": 0.14; '"n"': 0.16; 'adam': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'scope.': 0.16; 'subject:operators': 0.16; 'syntactic': 0.16; 'wrote:': 0.18; 'implementing': 0.19; 'resolved': 0.19; 'cc:addr:python.org': 0.22; 'fairly': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'operators': 0.31; 'could': 0.34; "can't": 0.35; 'something': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'similar': 0.36; 'error.': 0.37; 'wrong': 0.37; 'implement': 0.38; 'pm,': 0.38; 'sure': 0.39; 'called': 0.40; 'most': 0.60; 'course': 0.61; 'effectively': 0.66; 'special': 0.74; '2015': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=sT337pRm8KCgT/UHs2a1IG4g8TLNtoMpz3ndnpYQnhQ=; b=P+A3Qf/Sa1yQrRuQgl7vX5XfmRqZKYAQVdhN0iMAOUVzDzaF00xgpLarvrM5kEJPrK 22380w6w1T1OUUaUh/FC9wXFWMXr1Y51X1Bm47mziMKTHhU4D4LVUBXMy13/L2+xvPkO nkrwkp6uXMA7c3wuGn2P5cllyXVbVi1yCjvPN9ACJr7fhmqiE1UsghWd3n33jZQsvmIW QI1iEiEf8wAS8qt8VMTPNN/fLYPoGmmXfIJ1iwaz7xUmubyw9EcPx01Ghb61tDfseoGi XyaqfVSnLwc8SAokWm1gqvRHJu2i5uhZ/pPevEzuzy7dlW4vv5qUWl2hnUZhmDX5mWit Jeog==
MIME-Version 1.0
X-Received by 10.43.39.1 with SMTP id tk1mr11180044icb.26.1432016735918; Mon, 18 May 2015 23:25:35 -0700 (PDT)
In-Reply-To <mje816$2kd$1@ger.gmane.org>
References <55579886.3010001@cdreimer.com> <mailman.118.1431989304.17265.python-list@python.org> <fabab250-d7a5-49f4-a9ef-359bd003a607@googlegroups.com> <mje816$2kd$1@ger.gmane.org>
Date Tue, 19 May 2015 16:25:35 +1000
Subject Re: Rule of order for dot operators?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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.121.1432016739.17265.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1432016739 news.xs4all.nl 2922 [2001:888:2000:d::a6]:46055
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:90827

Show key headers only | View raw


On Tue, May 19, 2015 at 12:43 PM, Ron Adam <ron3200@gmail.com> wrote:
> Having just implementing something similar for nested scopes, it turns out
> it can't be operators because if it was, then the names y and z would be
> resolved in the wrong scope.
>
>          y = "m"
>          z = "n"
>          a = x . y . z
>
> Which of course wouldn't do what we want.
>
>          a = x . "m" . "n"
>
> And most likely this would give an error.

If you want to implement the dot as an operator, you could do it by
having a special syntactic element called an "atom", which is used for
these kinds of identifier-like tokens. The dot operator could then
take an object and an atom, and effectively return getattr(obj,
stringify(atom)). I'm fairly sure this would result in the same syntax
as Python uses.

ChrisA

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


Thread

Re: Rule of order for dot operators? Cameron Simpson <cs@zip.com.au> - 2015-05-19 08:29 +1000
  Re: Rule of order for dot operators? Rustom Mody <rustompmody@gmail.com> - 2015-05-18 18:32 -0700
    Re: Rule of order for dot operators? Ron Adam <ron3200@gmail.com> - 2015-05-18 22:43 -0400
    Re: Rule of order for dot operators? Chris Angelico <rosuav@gmail.com> - 2015-05-19 16:25 +1000
    Re: Rule of order for dot operators? Ron Adam <ron3200@gmail.com> - 2015-05-19 14:02 -0400
  Re: Rule of order for dot operators? albert@spenarnc.xs4all.nl (Albert van der Horst) - 2015-06-08 11:21 +0000
    Re: Rule of order for dot operators? Steven D'Aprano <steve@pearwood.info> - 2015-06-08 23:06 +1000

csiph-web