Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Joonas Liik Newsgroups: comp.lang.python Subject: Re: Method Chaining Date: Sat, 18 Jun 2016 17:05:25 +0300 Lines: 54 Message-ID: References: <74831a84-7b05-4242-b4c0-4a90d147717b@googlegroups.com> <33f73a24-4dcf-429b-9264-a3f3098f1cc3@googlegroups.com> <5763c2a7$0$1602$c3e8da3$5496439d@news.astraweb.com> <2dffea93-3dbd-4d04-93ed-6e02e3dd8660@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de zznsq1yIu/Xy8bAxQxewIwxNiThu76kPQre4VZVvc28w== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; 'context': 0.05; 'removes': 0.05; 'friday,': 0.07; 'modifying': 0.07; 'url:msdn': 0.07; 'cc:addr:python-list': 0.09; 'ambiguity': 0.09; 'naturally': 0.09; 'subtle': 0.09; 'python': 0.10; 'def': 0.13; '2016': 0.16; 'cc:name:python': 0.16; 'chained': 0.16; 'received:209.85.223.173': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'url:faq': 0.16; 'wrote:': 0.16; 'pfxlen:0': 0.18; 'version.': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'header:In-Reply-To:1': 0.24; 'equivalent': 0.27; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'towards': 0.28; 'faq:': 0.29; 'now?': 0.29; 'oop': 0.29; "i'm": 0.30; 'url:mailman': 0.30; 'statement': 0.32; 'class': 0.33; 'url:python': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'surely': 0.33; 'url:listinfo': 0.34; 'this?': 0.34; 'received:google.com': 0.35; 'something': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'cases': 0.36; 'url:library': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'difference': 0.38; 'version': 0.38; 'received:209': 0.38; 'mean': 0.38; 'does': 0.39; 'from:': 0.39; 'url:mail': 0.40; 'future': 0.60; 'care': 0.60; 'your': 0.60; 'leading': 0.61; 'here.': 0.62; 'more': 0.63; 'between': 0.65; 'url:en-us': 0.72; 'batchelder': 0.84; 'here!': 0.84; 'lean': 0.84; 'tastes': 0.84; 'utc+5:30,': 0.84; 'worth,': 0.84 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 :cc; bh=Eqna9k+ga1eiqc977tw3tXajCbtMyswGkJlFs1ukXs8=; b=kkPyrfDRAaNCE/ggsI5zV6vBeRHMFQNEXevrmw36mdc8myDEzHqvYO+RwiZz9YeSss uD+MMUWMt0+PsfG/ME+JdZguT5X5ELL+Jr2f2mbOEdWhm0AtlqzoW5uxlHOJ6SMwMQcD L2ttF+wA+mSxxWt2fQIt77Q5m5zM1Z7WlZLtwQDNQy7jzet0Y1eFiE3s13BKCTDnGg4O z7mxJdUv/wnXtNB32Y++atUBEbYMxeeteoN5HhkkGDhDE6MvEc8IPFpc06TWqNu2vfWz EeRDgZzFdijLJGbNEBQVZXpYcQsV5D4dSVr03eyYAkuZRMojiTvhlI4K3SJZV4p69JyS pNuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Eqna9k+ga1eiqc977tw3tXajCbtMyswGkJlFs1ukXs8=; b=aK85K+ADruqBev5+9qeYa0XHtpMNWGMxClGe9+Z1fXuvRiCZaga3LR/lIzMipcKpgJ XFk8vTT4GI4v5E9LyYNZVrzf7v2JJHG/wAZfIK4yOHG5PrZTcsOpQ07FIKz7H1DGvq0p Sv0/pJ6ZWIVKSht67XGsi5wzs7sbWrXzGMSsmVWa8JCQ95LsULWpGF104FTs307O51wl G+TTf6HfOUgZ4T1eQCbiDiatHCwM5q0o9f37xWazZP4Cxi8Q2OiJCmy8UWxOp183gdm0 WmCq44xOwMhxXK32Xu8UBqWCkw47p6DmdGK4oSg7bTJUsAXC2TyMtq+IHV3q8nW2fxBM KhPQ== X-Gm-Message-State: ALyK8tKcUL6pGRBGS7DbUXH/YIm41r0OtTQVPEQy0hui90cIyMzpREOXRpFgMZrZZYxxGxZXPgh/GIJrxn/VOg== X-Received: by 10.107.173.196 with SMTP id m65mr11151736ioo.131.1466258726531; Sat, 18 Jun 2016 07:05:26 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <74831a84-7b05-4242-b4c0-4a90d147717b@googlegroups.com> <33f73a24-4dcf-429b-9264-a3f3098f1cc3@googlegroups.com> <5763c2a7$0$1602$c3e8da3$5496439d@news.astraweb.com> <2dffea93-3dbd-4d04-93ed-6e02e3dd8660@googlegroups.com> Xref: csiph.com comp.lang.python:110099 On 18 June 2016 at 15:04, Pete Forman wrote: > Rustom Mody writes: > >> On Friday, June 17, 2016 at 2:58:19 PM UTC+5:30, Steven D'Aprano wrote: >>> On Fri, 17 Jun 2016 06:13 pm, Ned Batchelder wrote: >>> >>> > To me, it's a toss-up. The chained version is nice in that it >>> > removes the repetition of "g". But the unchained version is more >>> > explicit, and avoids the awkward parenthesis. >>> > >>> > I think I would lean toward the unchained version. Clearly tastes >>> > can differ. >>> >>> Indeed. For what it's worth, I'm ever-so-slightly leaning towards >>> Lawrence's taste here. >> >> More than 'slightly' out here! >> One thing about python OOP that irritates me is the 'self.' clutter. >> With a Pascal/VB style with-statement its naturally taken care of >> >> Yeah I know there is this FAQ: >> https://docs.python.org/2/faq/design.html#why-doesn-t-python-have-a-with-statement-for-attribute-assignments >> >> I consider it bogus if we allow with to mean something like: >> https://msdn.microsoft.com/en-us/library/wc500chb.aspx > > One subtle difference between your two citations is that VB uses a > leading dot. Might that lessening of ambiguity enable a future Python to > allow this? > > class Foo: > def .set(a): # equivalent to def set(self, a): > .a = a # equivalent to self.a = a > > Unless it is in a with statement > > with obj: > .a = 1 # equivalent to obj.a = 1 > .total = .total + 1 # obj.total = obj.total + 1 > > -- > Pete Forman > -- > https://mail.python.org/mailman/listinfo/python-list the leading dot does not resolve the ambiguity that arises from: with ob_a: with ob_b: .attr_c = 42 # which object are we modifying right now? also refer to "javascript the bad parts" about all the edege cases that python would surely face. also with is allready used for context managers..