[Python-ideas] (no subject)

Chris Angelico rosuav at gmail.com
Fri May 8 18:13:47 CEST 2015


On Sat, May 9, 2015 at 2:05 AM, Ron Adam <ron3200 at gmail.com> wrote:
> I don't think special syntax has an advantage over a function for this.  It
> may even be a disadvantage. The problem with special syntax is it can't be
> represented as data easily.  That would be counter to a functional style of
> programming, which seems at odds with the desired feature. (IMO)
>
>      fns = (set, list, sorted)
>      result = apply(data, *fns)

There's no problem with representing it as data; just like elsewhere
in Python, you can break out a subexpression and give it a name.

(a @ b @ c)(x)
# <=>
f = (a @ b @ c)
f(x)

It's no different from method calls:

sys.stdout.write("Hello, world!\n")
# <=>
write = sys.stdout.write
write("Hello, world!\n")

ChrisA


More information about the Python-ideas mailing list