[issue10836] TypeError during exception handling in urllib.request.urlretrieve

2011-01-05 Thread Alexandru Moșoi
New submission from Alexandru Moșoi : If I try to download a inexistent file I get a TypeError which is thrown during exception handling. >>> import urllib.request >>> urllib.request.urlretrieve('missing') Traceback (most recent call last): File "/usr/lib/p

[issue9547] iterator length

2010-08-09 Thread Alexandru Moșoi
New submission from Alexandru Moșoi : Sometimes it's useful to get the number of elements yield by an iterator. For example (if ilen is the name of the function): def pi(n): return ilen(for e in xrange(n) if isprime(e)) def count_pred(pred, iterator): return ilen(itertools.ifilter