From: Frank B. <fb...@fo...> - 2003-11-03 19:01:30
|
Hallo, Ian Bicking hat gesagt: // Ian Bicking wrote: > On Nov 3, 2003, at 10:51 AM, Frank Barknecht wrote: > There's a wonky behavior in list() (and maybe various related methods) > where it will get the length before iterating over the value, > presumably so it can pre-allocate space. Drove me nuts, because it > ignores any exceptions and so seems very magical. > > As a result I actually got rid of __len__ at some point (hmm... maybe > between 0.4 and 0.5, though if so I forgot to document it), and > replaced it with a .count() method so database calls wouldn't be > implicitly triggered. Sadly this ruins truth-testing, though maybe > that was dangerous too. > > Anyway, this shouldn't happen in 0.5. Hm, I'm using current CVS, and there SQLObject.py still has a __len__, but no "count" method. I actually don't use a pure list in my code but a class called "ProductDisplay" derived from list. With some little changes I could make without inheriting from list: I only use "for x in productDisplay_instance: do things" which should be possible without ProductDisplay being a list. Would going this route help? ciao -- Frank Barknecht _ ______footils.org__ |