[Python-ideas] Dart-like method cascading operator in Python

Masklinn masklinn at masklinn.net
Thu Nov 21 20:10:40 CET 2013


On 2013-11-21, at 18:26 , Andrew Barnert <abarnert at yahoo.com> wrote:
> Is it really that hard to name a plot "p"? Is typing “p.", or reading it, more work than ".."?

What’s the point of anything then?

    p = gnuplot.newPlot()
    p.set(‘xrange [0:5]’)
    p.set(‘xrange [0:20]’)
    n = p.newPlot()
    n.addSeries(“Linear”, [1, 2, 3])
    n.addSeries(“Quadratic”, [1, 4, 6])
    p.run()

is terser and adds no more pressure to the local namespace, the only
loss is the pseudo-nested formatting and that’s not really a core goal
of cascading.

> So if this is any part of the argument for the proposal, I'm -1.

As far as there’s any interest to cascading it’s that it’s terser
than sequencing calls with explicit receivers, and that it’s an
expression allowing inline initialisation sequences and not requiring
creating a binding.


More information about the Python-ideas mailing list