Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Joonas Liik Newsgroups: comp.lang.python Subject: Re: Method Chaining Date: Sun, 19 Jun 2016 14:56:44 +0300 Lines: 37 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> <5765B36F.5010506@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de DRYS43n1/qyMFni4eqR9ZQgIOPhGg6NXdvcn8EKOMlow== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.030 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'modifying': 0.07; 'cc:addr :python-list': 0.09; 'ambiguity': 0.09; '2016': 0.16; 'cc:name:python': 0.16; 'innermost': 0.16; 'joonas': 0.16; 'liik': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'attribute': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'bit': 0.23; 'header:In- Reply-To:1': 0.24; 'bugs': 0.27; 'equivalent': 0.27; 'message- id:@mail.gmail.com': 0.27; 'now?': 0.29; 'obscure': 0.29; '~ethan~': 0.29; 'url:mailman': 0.30; 'code': 0.30; 'writes': 0.30; 'url:python': 0.33; 'url:listinfo': 0.34; 'structure': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'anything': 0.38; 'why': 0.39; 'does': 0.39; 'received:209.85.214': 0.39; 'from:': 0.39; 'url:mail': 0.40; 'leading': 0.61; 'real': 0.62; 'back': 0.62; 'is.': 0.63; 'fall': 0.66; 'does?': 0.84; 'pain': 0.84; 'ethan': 0.91; 'furman': 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 :cc; bh=xeucUEpUlzOEJH+2vD7SVeKXDB0Ltw0gu/YrO8QVFBY=; b=Z/BSuDaZN2aMeyq+KI0X4Jriw/EYYo4/wBdXR+wkjbSKVlg3iAKRt9qV4LQjYdeW6p pSG6oV/Ft2tveyvoamudvuYGIJJRGFcruvyR3y/PPpA7vZib4ArWFvSsV3FyFM7bEuYs inamJMt0KJqQmAlmXtqT6mIrQ4nUmYHlNAB4IA6f+e0WPwx6McvCKM+0aNT/sv9crB5B DyNiwt8cUQWffqAV1szP4NQCTwPu2OFUIupzFUF7dG8nP0615+Jbo8LWYrz/RRMf/bX/ ZUTbh2yLqbwzFk2YglguAZcPmRfkpVQHjzSvBaFUSECMBFsDrHXlNw8nLKq4/UwjbyPh 4rug== 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=xeucUEpUlzOEJH+2vD7SVeKXDB0Ltw0gu/YrO8QVFBY=; b=LtJaBfjuerhNRxJNRJe516auI3jjcWT1oS5EmPAUKmVLdHzOdZogR2UxjkxUaFoWgN k/fAKUbNR81MH0SxJ40mVyrl2E5JgfZASgzGaV4AkSeU/LTfB9/jrChMuQcAC5ZEAVyV Brvt6YyQ5T4cqH84xyJn6/4hCQb2xeQJplo5wNJ34NnJHatM1NIvkaLfDk/nD2L1iadU 4ChhZv2PSwhkVh0U692svSHc2wtAy9u95V6Yzjc/Sj231Ghw928+MuydiBdAf2/yPar/ mUgnBB8QTlIytmM+tN+AKbEODGdPaargY1dxh7/QjrN6iD84vEniLIazj4chcipIg7Ty HAaw== X-Gm-Message-State: ALyK8tIHovDuQeAjELw96+QJLs78ccbeG0EU34qvoRH/oM/Hz3OXhi3tai1O8qBYELahd+O29WOQ+OOp/2zRBA== X-Received: by 10.36.134.3 with SMTP id u3mr9613332itd.23.1466337405166; Sun, 19 Jun 2016 04:56:45 -0700 (PDT) In-Reply-To: <5765B36F.5010506@stoneleaf.us> 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> <5765B36F.5010506@stoneleaf.us> Xref: csiph.com comp.lang.python:110138 On 18 June 2016 at 23:47, Ethan Furman wrote: > On 06/18/2016 07:05 AM, Joonas Liik wrote: >> >> On 18 June 2016 at 15:04, Pete Forman wrote: > > >>> with obj: >>> .a = 1 # equivalent to obj.a = 1 >>> .total = .total + 1 # obj.total = obj.total + 1 >> >> >> 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? > > > The innermost one. Why would it be anything else? > > -- > ~Ethan~ > > -- > https://mail.python.org/mailman/listinfo/python-list What if ob_b does not have attribute attr_c but ob_a does? This may be simple for a computer to solve - try looking it up on ob_b and fall back to ob_a if ob_b has no such attr.. but it is hard(er) to reason about for a human. You need to know about the inner structure of ob_b. not an issue for the person who writes it at first (unless 2 months have passed ) but a real pain if you are seeing that bit of code for the first time or are not intimately familiar with what ob_b is. Not unsolvable ofc, but makes it easier for obscure bugs to hide.