[Python-ideas] Anonymous blocks (again):

Andrew Barnert abarnert at yahoo.com
Mon May 13 23:07:03 CEST 2013


On May 13, 2013, at 13:19, Jonathan Eunice <jonathan.eunice at gmail.com> wrote:

> That many Python functions don't produce useful values makes 
> it difficult or impossible to do "chained" or "fluent" operations a la 
> JavaScript or Perl. 

Fluency and a clean expression/statement divide are almost directly contrary goals.

Similarly, reducing "vertical" code and making all structure explicit are almost directly contrary goals.

So;

> I love that Python avoids "expression soup" and long run-on 
> invocations, but the lack of appreciable support for "fluency" or even
> a smidgeon of functional style seems to regularly "verticalize" 
> Python code

If you made Python fluent, you would allow, and maybe even encourage, JS-style "expression soup". It's a tradeoff, and I think Python made the right choice here.

I've got a lot of logic that I migrate back and forth between Python and JS, and it's definitely true that a 3-line JS function often becomes a 5-line Python function and vice versa. But the Python function is nevertheless usually faster to read, so I don't think this is a problem.

> , with several lines required do common things, such as 
> fully construct / initialize / setup an object.  

Often the answer to that is that the right API for a Python class isn't the same as the right API for a similar JS prototype. For example, because pythonic style makes much more use of exceptions than typical JS style, you don't need multistage initialization nearly as often.



More information about the Python-ideas mailing list