[Python-ideas] Control Flow - Never Executed Loop Body

Sjoerd Job Postmus sjoerdjob at sjec.nl
Thu Mar 24 02:39:55 EDT 2016


Let me start by saying I'm not against the proposal, and think it could
make a lot of sense when properly implemented. However, I would like to
specificially respond to the following.

On Wed, Mar 23, 2016 at 09:17:32PM +0100, Sven R. Kunze wrote:
> On 23.03.2016 00:56, Andrew Barnert via Python-ideas wrote:
> >The only question is whether any of them are obvious enough (even
> >for novices). If not, we could argue whether any proposed change
> >would be significantly _more_ obvious. And, if so, then the
> >question is whether the change is worth the cost. But I think what
> >we have is already obvious enough.
> 
> It was reasonable for both Django and for jinja2 to add this. People
> actually asked for it https://github.com/mitsuhiko/jinja2/issues/77

It would be good to remember that both Django and jinja2 are templating
languages, and as such they impose different constraints on the user,
as well as the sentiment that templates should be (nearly) devoid of all
logic. Due to those constraints, adding an `empty` in the template
language makes a lot more sense than in a general-purpose programming
language.

Not to mention the fact that representing 'no results' as an empty page
is bad UX, but representing 'no results' from an API as an empty [list,
generator, ...] is good design.

Again, I like the proposal for the edge-cases it tries to solve (and
sometimes I have seen use-cases where it makes sense), but please make
sure you have better arguments and examples than 'look at Django and
jinja2'.


More information about the Python-ideas mailing list