The following code return an error KeyError: 500
def my_func(self, limit, list_type, **args):
type2abbr = {"allcategories": "ac", "categorymembers":"cm"}
abbr = type2abbr[list_type]
yield abbr
if __name__ == "__main__":
abbr = my_func(500, "categorymembers")
print abbr
Output:
Traceback (most recent call last):
File "dater.py", line 72, in
bot.start()
File "dater.py", line 56, in start
for title, text in self.pages:
File "dater.py", line 25, in page_generator
for item in self.cats:
File "/home/ceradon/api.py", line 305, in list
abbr = type2abbr[list_type]
KeyError: 500
Can anyone help me figure this out please?
list_typeis 500. You'd have to help us understand why.yieldstatement. Are you sure you wantyieldand not simplyreturn?self?