On 3/23/06, Ian Bicking <[EMAIL PROTECTED]> wrote: > This has been my personal experience with the iterators in SQLObject as > well. The fact that an empty iterator is true tends to cause particular > problems in that case, though I notice iterkeys() acts properly in this > case; maybe part of the issue is that I'm actually using iterables > instead of iterators, where I can't actually test the truthfulness.
This sounds like some kind of fundamental confusion -- you should never be tempted to test an iterator for its truth value. I wonder if the confusion lies in the API similarities with dict, which *does* return an iterable (not an iterator) from keys() etc.? Other objects that return iterators() from the same API are not obeying the (2.x) API contract for maps. > Another issue I have with generators (and hence iterators) is the > uselessness of repr() on them. This causes a lot of list() invocations > as well, which works with interactive testing, but fails badly with > print statements (where you have to do another run with list() around it > -- but that itself causes problems when exhausting the iterator > introduces a new bug). Views could solve this problem as well, since they are reiterable. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com