I have a lot of code that looks vaguely like this:

    if employees.count():
        for emp in employees:
            print emp

That code requires that the employees object is a selectResults object,
not a list.  When employees is a list, I write the same code this way:

    if employees:
        for emp in employees:
            print emp

More than a few times, I forget if I'm working on a selectResults
instance or on a list.

If we add a method to the selectResults class like this:

    def __nonzero__(self):
        return self.count()

Then I would never need to keep track of the nature of my employees
object.

This would REALLY help me out.

If anyone else likes this idea, let me know, and I'll write a patch.

Matt


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to