Don Arbow wrote:
Python 2.5 has any() and all() to replace reduce(). So I believe you
could do this:
list = Model.objects.filter(any([Q(name__startswith=letter) for letter
in 'abc']))
the goal here isn't to check if any of the Q's are true, it's to join
together all the Q's with the "binary or" operator (|). any() doesn't
do that:
>>> class obj:
... def __init__(self, name):
... self.name = name
... def __or__(self, other):
... print "OR", self.name, other.name
... return self
... def __repr__(self):
... return "<object %s>" % self.name
...
>>> obj("A") | obj("B") | obj("C")
OR A B
OR A C
<object A>
>>> any([obj("A"), obj("B"), obj("C")])
True
</F>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---