Method returning an Iterable Object

Anjanesh Lekshminarayanan mail at anjanesh.net
Mon Jan 26 11:31:21 EST 2009


Is there a way to return an iterable object ?

class twoTimes:
    def __init__(self, n):
        self.__n = n

    def getNext():
        self.__n *= 2
        return self.__n


t = twoTimes(5)
while (n in t.getNext()): # while (n in t):
    print (n)

-- 
Anjanesh Lekshmnarayanan



More information about the Python-list mailing list