[Python-ideas] Enhance definition of functions

Ryan rymg19 at gmail.com
Tue Jul 30 20:30:13 CEST 2013


How about something like:

f = indef(x, y): print x, y

It's essentially storing lambdas. The syntax was taken from http://blog.deliciousrobots.com/2010/3/24/a-simple-compiler-with-python-and-ply-step-1-parsing/. indef stands for 'inline definition'. I've never heard someone use that name before. Or you could do 'slambda' for 'stored lambda'.

Musical Notation <musicdenotation at gmail.com> wrote:

>Yes, I know that multiline lambda will never be implemented in Python,
>but in many languages it is possible to write an anonymous function
>without using lambda at all.
>In JavaScript:
>Instead of "function <name>(<variables>){code}" you can write "var
>name; name=function(<variables>){code}"
>Python (proposed):
>def func(a,b):
>    print(a+b)
>    return a+b
>
>becomes
>
>func=function a,b:
>    print(a+b)
>    return a+b
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Python-ideas mailing list
>Python-ideas at python.org
>http://mail.python.org/mailman/listinfo/python-ideas

-- 
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130730/2fb1b98e/attachment-0001.html>


More information about the Python-ideas mailing list