a with-statement that executes blocks instead of wrapping code
This entry was posted
on Thursday, November 15th, 2007 at 4:46 pm and tagged as thoughts, antizen, python.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
3 Responses to “Python Wishlist”
You will get 1 and 2 in Python 3.0.
Not sure what you are after in 3, but if you want the ability to set variables in an enclosing scope you have that in 2.6.
You will never get 3, period. Too prone to errors by overlooking the assignment. Or a typo where you meant a comparison.
Not sure what you are after for 4.
5 is not going to happen as that would require new syntax that we most likely would have found by now for lambda.
Comment by Brett —
Friday, November 16th, 2007 @
2:52 am
I think you mixed up the numbers. Coroutines is something I normally don’t miss. But when it comes to writing, say, a mod_python compatibility interface for WSGI you would need coroutines, otherwise there is no way to make a request.write(”…”) emit a yield “…”.
I know that the assignments as expressions thing is something I will never get but I can tell you that I know countless people that think Python is lacking exactly that :-)
The scoping problems I have are mostly fixed in Python 3 with the introduction of the nonlocal keyword. However because assignments are not expressions and afair nonlocal is no expression either we still can’t do “something(lambda x: nonlocal foo = x)” and have to create a function in a function (which yes, is the same, but a lot more verbose).
Yes, with backwards compatibility for the current with one would have to find a new syntax for that.
You will get 1 and 2 in Python 3.0.
Not sure what you are after in 3, but if you want the ability to set variables in an enclosing scope you have that in 2.6.
You will never get 3, period. Too prone to errors by overlooking the assignment. Or a typo where you meant a comparison.
Not sure what you are after for 4.
5 is not going to happen as that would require new syntax that we most likely would have found by now for lambda.
Comment by Brett — Friday, November 16th, 2007 @ 2:52 amI think you mixed up the numbers. Coroutines is something I normally don’t miss. But when it comes to writing, say, a mod_python compatibility interface for WSGI you would need coroutines, otherwise there is no way to make a request.write(”…”) emit a yield “…”.
I know that the assignments as expressions thing is something I will never get but I can tell you that I know countless people that think Python is lacking exactly that :-)
The scoping problems I have are mostly fixed in Python 3 with the introduction of the nonlocal keyword. However because assignments are not expressions and afair nonlocal is no expression either we still can’t do “something(lambda x: nonlocal foo = x)” and have to create a function in a function (which yes, is the same, but a lot more verbose).
Yes, with backwards compatibility for the current with one would have to find a new syntax for that.
Regards,
Comment by Armin Ronacher — Friday, November 16th, 2007 @ 9:11 amArmin
Stackless python has coroutines
Comment by Brynjar — Thursday, November 29th, 2007 @ 9:41 am