On 10/11/2016 07:00 AM, Steven D'Aprano wrote:
On Tue, Oct 11, 2016 at 02:41:34PM +0200, Sven R. Kunze wrote:

on django-developers, an intriguing idea appeared:
https://groups.google.com/d/msg/django-developers/4bntzg1HwwY/HHHjbDnLBQAJ

"""
It seems to me that the default `method.__bool__` is undesirable in
Jinja2 templates. I do not know Jinja2 well enough, but maybe they could
benefit from a patch where `if`-statements give a warning/error when the
expression is a callable (with the default `FunctionType.__bool__`?
This would solve the issue not just for the methods you mention, but
more in general.

That should be easy enough to do as a custom descriptor.

But I would not like to see the default function or method __bool__
raise a warning.

[...]

So I think this is something that Django/Jinja2 should implement for its
own methods that need it, it should not be a general feature of all
Python functions/methods.

Agreed. Python is a /general/-purpose programming language.  We should not make 
changes to help one subset of users when those changes will harm another subset 
(and being flooded with false positives is harmful) -- particularly when easy 
customization is already available.

--
~Ethan~
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to