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


Groups > comp.lang.python > #110046

Re: Method Chaining

Path csiph.com!feeder.erje.net!1.eu.feeder.erje.net!newsfeed0.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail
From Michael Selik <michael.selik@gmail.com>
Newsgroups comp.lang.python
Subject Re: Method Chaining
Date Fri, 17 Jun 2016 04:23:57 +0000
Lines 33
Message-ID <mailman.99.1466137450.2288.python-list@python.org> (permalink)
References <74831a84-7b05-4242-b4c0-4a90d147717b@googlegroups.com> <CAGgTfkPETwxb8kx1PcR+F5qVEm-pkxHFDE4=aw+WNE2itsM3+w@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de qO62uHwRb7cJDCzmYd3y2AWerJZ0MaST07m5GAc4NDlg==
Return-Path <michael.selik@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; '16,': 0.03; '<>,': 0.07; 'repeated': 0.07; 'none.': 0.09; 'thu,': 0.15; '2016': 0.16; 'extraneous': 0.16; 'p2)': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sequence:': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'drawing': 0.18; 'email addr:gmail.com&gt;': 0.18; 'to:2**1': 0.21; 'lawrence': 0.22; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'message-id:@mail.gmail.com': 0.27; 'tend': 0.27; 'function': 0.28; 'received:google.com': 0.35; 'sometimes': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'received:209.85.220': 0.38; 'to:addr:python.org': 0.40
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=bTXZf+7TXUALahz372KQyH5byjAwf8uEZbr+DUJCKfQ=; b=Uyyu2snIjGIkXMNR7hqfwVIe2TIp5pKOg9/LCtYl9o8fMK5RH4x4x7tM8+lEheRydA UBog3R+d5z/f2dYYkRTRM3qjIF2b4c+vvh/FqVXsiL6/uRb8et9fhnjZYssbz4pundBJ mNpBA189ov8ewY0pLErYU76Z36iXCYwH5/4OLZZSD1fgxNzn2h5DcCFcXrcu9uG99/Cb JTx3pJ3spL0aYsm7K8+vzgXe3RKI83PwY6ccYEHWc/WYqRPgatjjPrscApybJbSt9bjR TmBm4PQYdjbplzUiQy2HlLIF0wYhioskPAIUnxtJ+RkckQyIXaPoYVyN9KKNaEcsI7/G oOYA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=bTXZf+7TXUALahz372KQyH5byjAwf8uEZbr+DUJCKfQ=; b=kn7xThgYeIb+VXqd5Y+akEi7sKGGBbdq8oJvIdWtdRNuazP8C3zficB8mSZEgVNowG BghzRh8R5+/uEXq8RMKIwx3xsoP6f5AMlnXNpZiVdvsH+pLiuETNONyv564tWj+MVe0y 9nl8ciARzde8oam5gVOAsqD2c++kk14BiGF+mjDcjQWGx9ZdPfngF/OXTc3c32/Zq3J6 2KtqqdE0yO5t0d+sLKScikQmofB7NTpqG3Nbu100LXGYBYu0w07ka9kuopV0hA+/wJR7 VxhUZxh/rsjQQ3Scjhw6ttaHLX6mha+3h5zmgQugcSTgkvtjSPJR+rEz4OBicWRvV8HI sJsg==
X-Gm-Message-State ALyK8tI50uCVVlPAMb31V1rH6bn6oDMI0OqB9E0W9wQYn5zDxw7FRtX9EEcFgyWZQ0LtYiBGJS3hMrJfhnLY4A==
X-Received by 10.200.48.46 with SMTP id f43mr83268qte.10.1466137447495; Thu, 16 Jun 2016 21:24:07 -0700 (PDT)
In-Reply-To <74831a84-7b05-4242-b4c0-4a90d147717b@googlegroups.com>
X-Content-Filtered-By Mailman/MimeDel 2.1.22
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
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>
X-Mailman-Original-Message-ID <CAGgTfkPETwxb8kx1PcR+F5qVEm-pkxHFDE4=aw+WNE2itsM3+w@mail.gmail.com>
X-Mailman-Original-References <74831a84-7b05-4242-b4c0-4a90d147717b@googlegroups.com>
Xref csiph.com comp.lang.python:110046

Show key headers only | View raw


On Thu, Jun 16, 2016 at 10:53 PM Lawrence D’Oliveiro <lawrencedo99@gmail.com>
wrote:

> Example from <http://default-cube.deviantart.com/art/Truchet-612095093>,
> concisely expressing a complex drawing sequence:
>
>     (g
>         .move_to((p1 + p2a) / 2)
>         .line_to(p1 + (p2 - p1) * frac)
>         .line_to((p1 + p1a) / 2)
>         .stroke()
>         .move_to((p2 + p2a) / 2)
>         .line_to(p2 + (p1 - p2) * frac)
>         .line_to((p2 + p1a) / 2)
>         .stroke()
>     )
>

Wouldn't that look nicer with the ``g`` repeated on every line, no extra
indentation, and no extraneous parentheses?

    g.move_to((p1 + p2a) / 2)
    g.line_to(p1 + (p2 - p1) * frac)
    g.line_to((p1 + p1a) / 2)
    g.stroke()
    g.move_to((p2 + p2a) / 2)
    g.line_to(p2 + (p1 - p2) * frac)
    g.line_to((p2 + p1a) / 2)
    g.stroke()

Sometimes it's hard to know when a function has a side-effect. I appreciate
that these impure functions tend to return None.

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


Thread

Method Chaining Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-16 19:02 -0700
  Re: Method Chaining Steven D'Aprano <steve@pearwood.info> - 2016-06-17 12:39 +1000
  Re: Method Chaining Michael Selik <michael.selik@gmail.com> - 2016-06-17 04:23 +0000
    Re: Method Chaining Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-16 21:37 -0700
      Re: Method Chaining Ned Batchelder <ned@nedbatchelder.com> - 2016-06-17 01:13 -0700
        Re: Method Chaining Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-17 01:38 -0700
          Re: Method Chaining Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-06-17 11:45 +0300
        Re: Method Chaining Steven D'Aprano <steve@pearwood.info> - 2016-06-17 19:28 +1000
          Re: Method Chaining Michael Selik <michael.selik@gmail.com> - 2016-06-17 13:34 +0000
            Re: Method Chaining Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-17 15:26 -0700
              Re: Method Chaining Michael Selik <michael.selik@gmail.com> - 2016-06-17 22:45 +0000
              Re: Method Chaining Michael Selik <michael.selik@gmail.com> - 2016-06-17 23:10 +0000
          Re: Method Chaining Rustom Mody <rustompmody@gmail.com> - 2016-06-17 09:48 -0700
            Re: Method Chaining Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-17 15:25 -0700
            Re: Method Chaining Pete Forman <petef4+usenet@gmail.com> - 2016-06-18 13:04 +0100
              Re: Method Chaining Joonas Liik <liik.joonas@gmail.com> - 2016-06-18 17:05 +0300
                Re: Method Chaining Pete Forman <petef4+usenet@gmail.com> - 2016-06-18 16:42 +0100
              Re: Method Chaining Rustom Mody <rustompmody@gmail.com> - 2016-06-18 08:35 -0700
                Re: Method Chaining Pete Forman <petef4+usenet@gmail.com> - 2016-06-19 11:16 +0100
              Re: Method Chaining Ethan Furman <ethan@stoneleaf.us> - 2016-06-18 13:47 -0700
              Re: Method Chaining Joonas Liik <liik.joonas@gmail.com> - 2016-06-19 14:56 +0300
              Re: Method Chaining Ethan Furman <ethan@stoneleaf.us> - 2016-06-19 08:01 -0700
              Re: Method Chaining Michael Torrie <torriem@gmail.com> - 2016-06-19 09:14 -0600
              Re: Method Chaining Ethan Furman <ethan@stoneleaf.us> - 2016-06-19 08:56 -0700
                Re: Method Chaining Rustom Mody <rustompmody@gmail.com> - 2016-06-19 09:03 -0700
        Re: Method Chaining Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-06-17 15:22 -0700
          Re: Method Chaining Ned Batchelder <ned@nedbatchelder.com> - 2016-06-17 17:02 -0700

csiph-web