On Mar 4, 2010, at 6:07 PM, Phlip wrote:

> Peter Herndon wrote:
> 
>> Won't the "in" filter do exactly what you need?
>> 
>> http://docs.djangoproject.com/en/1.1/ref/models/querysets/#in
> 
> Why do you need even __in? Given...
> 
>  Entry.objects.filter(id__in=[1, 3, 4])
> 
> ...couldn't id=[] overload if the target is a list?

I suppose it could if it were written that way, but it isn't.  The filter form 
"filter(<field>=<value>)" is shorthand for the form 
"filter(<field>__exact=<value>)".  To my knowledge, no one has written an 
operator overload for a Django filter operation.  I could of course be mistaken 
about that, but in my opinion, such overloading would go against the Python 
philosophy that "explicit is better than implicit."  Since an "in" operator 
already exists, and is a direct analog of the SQL "IN" operator, using that 
seems preferable.  Again, assuming I'm properly understanding the original 
poster's problem.

I believe, from reading your recent back-and-forth with James, that you are 
looking for ways to reduce the amount of code you need to type.  Neither Python 
nor Django are oriented towards code brevity as their primary motivation; 
instead, ensuring that code can be easily read and understood is primary.  
Occasionally, legibility clashes with brevity, as you've pointed out.  I 
personally find this emphasis to be a pleasant release from being forced to 
interpret code that is obfuscated by its brevity.  But that's just my 
preference.  

---Peter

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to