Method returning an Iterable Object

Anjanesh Lekshminarayanan mail at anjanesh.net
Mon Jan 26 17:31:21 CET 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