unfortunately, __len__() has the unwanted side effect of being consulted when the Query object is evaluated in a list context, meaning if you say list(query), __len__() is called first before __iter__() and has the effect of two SQL statements being issued. so we can't integrate __len__() (though we've certainly wanted to).
On Mar 8, 2008, at 10:12 AM, Thomas Wittek wrote: > > Hi! > > As I can also use several list operations on a Query instance (like > access by index, slicing, ...) it might be a good idea to add __len__, > so that I can use the pythonic len(query). > > The patch would be trivial (unless there are some internal issues that > I don't know). > Just add this method to the Query class: > > def __len__(self): > return self.count() > > What do you think? > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---