I am working on a Django project (using the latest dev version, as of a few days ago) in which I use Q objects quite a bit to build up queries dynamically. I like that the binary & and | operators are overloaded to AND and OR queries together with QAnd and QOr, but I was surprised that the unary ~ operator isn't overloaded to NOT a query with QNot. This would be a handy piece of sugar -- if nothing else, it would mean that I only need to import Q instead of Q and QNot -- and (I think) it would be as simple as adding the method:
def __invert__(self): return QNot(self): to the Q and QOperator classes in django.db.models.query. For a little extra efficiency, it should probably be overridden in the QNot class to be: def __invert__(self): return self.q # two NOTs cancel each other out If there's a reason not to do this, I'd be curious to know what it is; otherwise, I think it might be a handy feature. -Femtomatt --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@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-developers?hl=en -~----------~----~----~----~------~----~------~--~---