On Mar 31, 2006, at 10:46 AM, Don Arbow wrote: > On Mar 31, 2006, at 8:05 AM, sam wrote: >> I was trying complex Q and notices if I do: >> >> complex=(Q1 | Q2) >> >> and >> >> complex = (Q1 or Q1) >> >> the results are not the same. I got right result using "or" but not >> with "|". Is this a bug or I did something wrong? What is the >> difference between these two operators? >> > > The vertical bar is a bitwise or. Unlike Perl, Python does not have a > synonym for the logical or.
Actually, what's going on is that Python doesn't let you overload the "or" operator, only the logical or "|" operator. So ``Q1 or Q2`` doesn't actually do at all what you want it to do; ``Q1 or Q2`` will actually evaluate to just ``Q1`` which is bad. Always use the "|" operator to combine Django queries (or string together multiple ``filter()`` clauses). Jacob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" 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-users -~----------~----~----~----~------~----~------~--~---

