Hi Sven,

Here are some examples of when the "is" operator isn't equivalent to "==".
http://stackoverflow.com/questions/3647692/when-is-the-operator-not-equivalent-to-the-is-operator-python

Preston (author of the patch to add the "is" operator [0]) indicated 
support for "is" was necessary for template-based widget rendering [1]. I 
haven't studied that patch closely, but maybe if you take a look you'll 
understand why it's needed.

I don't see much benefit to your proposal of limiting its usage to 
comparing boolean/None values.

[0] https://code.djangoproject.com/ticket/26118
[1] https://github.com/django/django/pull/4848

On Wednesday, April 13, 2016 at 4:35:34 PM UTC-4, Sven R. Kunze wrote:
>
> Good evening everybody. That's my first post here, so let's how this 
> works. :)
>
> This particular discussion caught my sight as it might introduce something 
> really "low-level" functionality into the template engine.
>
>
> I can contribute here to the "design consideration" that from my 
> experience with other (less experienced) developers it that the difference 
> of "is" and "==" is not quite easy to explain (as illustrated by this 
> thread as well). So, I am not 100% convinced that "is" and "is not" is a 
> valid use-case for a template language but I may miss some important piece 
> here.
>
>
> However, given the docs and tests added in the patch, it seems the 
> intended use-case for this kind of feature is to check for "is None", "is 
> not None", "is True", "is not True" etc. Would it makes sense to hard-wire 
> those specific use-cases instead?
>
> (Admittedly, even those can be implemented using "==".)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/47be46cb-5224-4f9e-8f92-986839c25658%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to