On 7/13/07, SmileyChris <[EMAIL PROTECTED]> wrote:
> Adrian, I think it's useful enough. But why do you need a .exists() if
> we could just use __nonzero__ (like Ivan suggested)?

I hadn't thought of that! Yes, we should definitely implement a
QuerySet.__nonzero__() method. However, I'd like there to be an
explicit method (named either exists() or any() or whatever), because
it's easier to say this:

    To determine whether a QuerySet has at least one record, call its
exists() method.

...than this:

    To determine whether a QuerySet has at least one record, put it in
an "if" statement

It's convenient to be able to access the result of exists() inline,
rather than having to use it in a certain context, such as within an
"if" clause. Sure, if we went with only __nonzero__(), you could call
__nonzero__() directly, but accessing the Python double-underscore
magic methods is slightly ugly. Make sense?

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to