hi this is the corotuıne example writen in def

namelst=['Charles Darwin (1809-82)', "Darwin's principal works, The Origin of Species (1859)", 'and The Descent of Man (1871) marked a new epoch in our', 'understanding of our world and ourselves.  His ideas', "were shaped by the Beagle's voyage around the world in", '1831-36.']

####PART 1 *****####################
def rotation(s):
	lst=list(s)
	cnt=0
	while len(lst):
		yield lst[cnt]
		cnt=(cnt +1) % len(lst)

r=rotation(namelst)
## PART 2****########
for x in range(8):
	print "turning: %s" % r.next()














#and ı want to write ıt with class by usıng ınherit
#according to ı know ınherit method was used when we want to add some fonctonalıty to our class
#so purposely ı want to dıvede ıt ınto 2 those classes
#and ı am stuck totaly at ımplemendıng the whıle loop


class rotator(object):
	def __init__(self):
		self.name=list
		self.lst=[]
	def setname(self, m):
		self.name=m
	def t(self):
		return self.name






S=rotator()
S.setname(namelst)
S.t()


def continueof(rotator):
	def __init__(self):
		sirano.__init__(self)
		self.cnt=0
	def __str__(self):
		sirano.__init__(self)
		while len(self.name):
			yield self.name[self.cnt]
			self.cnt=(self.cnt+ 1) % len(self.name)
	def nexter(self):
		for x in range(5):
			print "turn: %s" % continueof.next()

d=continueof(namelst)

d.__str__()
>>> d.nexter()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'nexter'
>>> 
# somethıng went wrong.ı used wrong method probably
>> d.__str__()

'None' # out put ıs NONE so ıt means there ıs no bypass data to whıle loop


how can ı pass the data to ınherıt class(

def continueof(rotator):
is a function, not a class.
You can't set it up like a class and use it like a class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.