#11687: The 'add' template filter only works for integers, and can fail noisily
---------------------------------------------+------------------------------
          Reporter:  thepointer              |         Owner:  gruszczy
            Status:  new                     |     Milestone:  1.2     
         Component:  Template system         |       Version:  1.1     
        Resolution:                          |      Keywords:          
             Stage:  Design decision needed  |     Has_patch:  1       
        Needs_docs:  0                       |   Needs_tests:  0       
Needs_better_patch:  0                       |  
---------------------------------------------+------------------------------
Comment (by gruszczy):

 I don't like sucking all exceptions and this shouldn't be done. Imagine
 there is a custom object, that can be cast to an int and during coercing
 it will raise a different exception. Why should user lose this
 information? This is completely contrary to python zen.

 When it comes to ducktyping, you have to remember, that the object on
 which filter is used, will have to able to accept a string as an argument
 of __add__. Most basic types:

 {{{
 In [1]: [] + ''
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)

 /home/gruszczy/<ipython console> in <module>()

 TypeError: can only concatenate list (not "str") to list

 In [2]: () + ''
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)

 /home/gruszczy/<ipython console> in <module>()

 TypeError: can only concatenate tuple (not "str") to tuple
 }}}

 just can't do this.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11687#comment:11>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to