On Fri, Sep 19, 2008 at 9:51 PM, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Extending len() to support iterables sounds like a good idea, except that > it's not. > > Here are two iterables: > > > def yes(): # like the Unix yes command > while True: > yield "y" > > def rand(total): > "Return random numbers up to a given total." > from random import random > tot = 0.0 > while tot < total: > x = random() > yield x > tot += x > > > What should len(yes()) and len(rand(100)) return?
Clearly, len(yes()) would never return, and len(rand(100)) would return a random integer not less than 101. -Miles -- http://mail.python.org/mailman/listinfo/python-list