On Tue, Feb 19, 2019 at 6:23 AM Jimmy Girardet <i...@netc.fr> wrote:

> Hi,
>
> There was the discussion about vector, etc...
>
> I think I have a frustration about chaining things easily in python in
> the stdlib where many libs like orm  do it great.
>
> Here an example :
>
> The code is useless, just to show the idea
>
> >>> 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.
>

Easy for you, but not necessarily everyone else. For instance, I find the
explicit writing out of the lines easier.

Also realize that design is on purpose so that mutating method calls on
lists do not return themselves to get the point across that the mutation
was in-place and not in fact a new list.

-Brett


>
> 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)
>
> >> object::callable()  = callable(object)
> >> object(arg)::callable = callable(object(arg))
>
> def callable(arg1,arg2):
>    pass
>
> >> object::callable(arg) == callable(object, arg)
>
> The idea is to use quite everything as first argument of any callable.
>
> I do not know if it was already discussed, and if it would be
> technically doable.
>
> Nice Day
> Jimmy
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
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