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


Groups > comp.lang.python > #90823

Re: Rule of order for dot operators?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.roellig-ltd.de!open-news-network.org!border2.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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; 'attribute': 0.07; 'binary': 0.07; 'nested': 0.07; 'string': 0.09; 'lookup': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'ron': 0.09; "wouldn't": 0.14; '"."': 0.16; '"n"': 0.16; '>in': 0.16; 'closures,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'scope,': 0.16; 'scope.': 0.16; 'subject:operators': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'implementing': 0.19; 'resolved': 0.19; 'header:User-Agent:1': 0.23; 'cheers,': 0.24; 'header:X-Complaints-To:1': 0.27; 'header :In-Reply-To:1': 0.27; 'resolution': 0.29; 'that.': 0.31; 'operators': 0.31; 'yes.': 0.31; 'url:python': 0.33; 'could': 0.34; "can't": 0.35; 'except': 0.35; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'next': 0.36; 'subject:?': 0.36; 'similar': 0.36; 'url:org': 0.36; 'error.': 0.37; 'wrong': 0.37; 'implement': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'course.': 0.60; 'most': 0.60; 'url:3': 0.61; 'course': 0.61; 'name': 0.63; 'more': 0.64; 'header:Reply-To:1': 0.67; 'anything.': 0.68; 'url:4': 0.69; 'reply-to:no real name:2**0': 0.71; 'reply-to:addr:gmail.com': 0.80
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ron Adam <ron3200@gmail.com>
Subject Re: Rule of order for dot operators?
Date Mon, 18 May 2015 22:43:49 -0400
References <55579886.3010001@cdreimer.com> <mailman.118.1431989304.17265.python-list@python.org> <fabab250-d7a5-49f4-a9ef-359bd003a607@googlegroups.com>
Reply-To ron3200@gmail.com
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host ip98-170-222-96.pn.at.cox.net
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0
In-Reply-To <fabab250-d7a5-49f4-a9ef-359bd003a607@googlegroups.com>
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.120.1432003441.17265.python-list@python.org> (permalink)
Lines 51
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1432003441 news.xs4all.nl 2845 [2001:888:2000:d::a6]:51305
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:90823

Show key headers only | View raw



On 05/18/2015 09:32 PM, Rustom Mody wrote:
>> >In particular, each .foo() need not return a string - it might return anything,
>> >and the following .bah() will work on that anything.
> For an arbitrary binary operator ◼
> x ◼ y ◼ z
> can group as
> (x◼y)◼z
> or
> x◼(y◼z)
>
> One could (conceivably) apply the same rule to x.y.z
> Except that x.(y.z) is a bit hard to give a meaning to!!

Yes.

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.


The name-part after the dot is evaluated in the next inner scope.  y is 
resolved in x's scope, and z is resolved in y's scope.

Which is why you can implement objects with closures, but you need to delay 
name resolution to do that.   Which is what the "." does.


Pythons attribute lookup is a bit more complex than this of course.

      https://docs.python.org/3.4/howto/descriptor.html


Cheers,
    Ron




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