> On Fri, 11 Sep 2015 at 10:41 Herbert Kruitbosch > <python-...@herbertkruitbosch.com> wrote: > __ >> data_sorted = sort(data, key = #1[0]) > > That syntax won't work because `#` is used to start a comment and > there is no way to disambiguate that in the grammar.
Obviously :) The #-syntax is used by Mathematica, which is why I used it here. As you stated, it is not adequate for python3. You could imagine a $n or ***n syntax. I'm not in any way well informed on the python3 syntax, nor what would be aesthetically appealing and readable. >> where the #1 is similar to the one used in Mathematica for the same >> purpose. That is, an expression with #1 becomes an anonymous >> function which takes one argument, and, obviously, if a #n is >> included, the anonymous function takes n arguments. >> >> Notice that #1[0] does not seem like partial function application, >> however it is if you (C++'isly) assume that the deference operation >> [] is a function dereference(subscriptable, subscript). >> >> Obviously, I am only expecting that you get these type of suggestions >> all the time and that there is a good change you do not find it >> adequate for many reasons, for example keeping the language compact. >> I this case, I would also like to hear so. > > In my code the few times I want partial function applications I have > found the functions in the operator module meet that need, else > functools.partial or a quickly written closure do the trick. I don't > think dedicated syntax is warranted when those other options already > exist to meet the same need. I would guess it depends on personal preference. And like you stated, there are many clear and intuitive workarounds. I never got to the point where functools.partial and operator.* became part of my coding equipment, and I would adore this feature. I'm very curious if there are more people on my team, but am also interested to hear about opinions against such a feature. > Thanks for the suggestion! No problem, and thank you for reading it :) Herbert
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com