Python iteration over non-sequence

后端 未结 4 1171
温柔的废话
温柔的废话 2021-01-04 01:16

I have this piece of code which creates a note and adds to the notebook. When I run this I get a Iteration over non-sequence error.

import datetime
class Not         


        
4条回答
  •  轮回少年
    2021-01-04 02:06

    The problem is in the line for note in Notes: since Notes is an object not a list. I believe you want for note in Notes.notes:

    also as unutbu pointed out, you can overload the __iter__ operator which will allow your current loop to work. It depends how you want this to outwardly appear. Personally I would overload __iter__

提交回复
热议问题