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
|