python - TypeError: object takes no parameters -


i'm trying create code utilizes __iter__() method generator, getting error saying:

typeerror: object() takes no parameters.

additionally, unsure whether yield function should called within try: or within main() function

i new python , coding, suggestions , advice appreciated can learn. thanks!

class counter(object):      def __init__(self, filename, characters):         self._characters = characters         self.index = -1          self.list = []         f = open(filename, 'r')         word in f.read().split():             n = word.strip('!?.,;:()$%')             n_r = n.rstrip()             if len(n) == self._characters:                 self.list.append(n)      def __iter(self):         return self      def next(self):         try:             self.index += 1             yield self.list[self.index]              except indexerror:                 raise stopiteration             f.close()  if __name__ == "__main__":     word in counter('agency.txt', 11):         print "%s' " % word 

use yield function __iter__:

class a(object):     def __init__(self, count):         self.count = count      def __iter__(self):         in range(self.count):             yield  in a(10):     print 

in case, __iter__ maybe looks this:

def __iter__(self):     in self.list:         yield 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -