Using an arbitrary maximum in range()
Question: Is there a way in Python to iterate over every integer until something
happens? Right now I tend to do one of the following:

    
    
    for i in range(999999999):
       ...
       if something:
           break
    

or

    
    
    i = 0
    status = True
    while status:
        ...
        if something:
            status = False
        i += 1
    

Both of these methods work for what I'm doing, but I'm sure there's a better
way to do it. Please point me in the right direction.


Answer: Try `itertools.count`.

    
    
    >>> import itertools
    >>> for x in itertools.count():
    ...     print x
    ...     if x > 10: break
    ...
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    

