class True(object): def __init__(self, iterations=1): self.iterations = iterations self.current_iteration = 0 def __nonzero__(self): if self.current_iteration < self.iterations: self.current_iteration += 1 return 1 return 0 if __name__ == "__main__": True = True(4) while True: print "Loop!"