I would suggest a small improvement: allow a trailing :: which is useful for when the last function does not return anything. So for example this
[1,2,3].append(4)::sort() will evaluate to None, but [1,2,3].append(4)::sort():: would evaluate to the list. > On 19 Feb 2019, at 15:13, 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. > > 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/