On Wed, Feb 20, 2019 at 1:22 AM Jimmy Girardet <i...@netc.fr> wrote:
> >>> a = [1,2,3]
> >>> a.append(4)
> >>> a.sort()
> >>> c = max(a) + 1
>
> I would be happy to have
> >>> [1,2,3].append(4)::sort()::max() +1
>
> It makes things very easy to read: first create list, then append 4,
> then sort, then get the max.
>
> To resume, the idea is to apply via a new operator (::, .., etc...) the
> following callable on the previous object. It's clearly  for standalone
> object or after a method call when the return is None (there is fluent
> `.` when there is a return value)

Hmm. The trouble is, there's no consistent "previous object" for each
of your steps. You're mixing together "max()" which is a built-in, and
"sort()" which is a method. Your proposed semantics (which I snipped)
will happily cover built-ins, but not methods.

Proposals broadly similar to these (but generally, if my memory
serves, focusing on methods only) have come up periodically. You may
want to briefly search the mailing list archives to find discussions
on "method chaining".

ChrisA
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to