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
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