importing module causes TypeError: module.__init__() takes at most 2 arguments (3 given)

前端 未结 4 746
醉梦人生
醉梦人生 2021-01-11 13:45

Please don\'t mark as duplicate, other similar questions did not solve my issue.

This is my setup

/main.py
/actions/ListitAction.py
/actions/ViewAction         


        
4条回答
  •  走了就别回头了
    2021-01-11 14:33

    Your imports are wrong, so you're trying to inherit from the modules themselves, not the classes (of the same name) defined inside them.

    from actions import ListitAction
    

    in ViewAction.py should be:

    from actions.ListitAction import ListitAction
    

    and similarly, all other uses should switch to explicit imports of from actions.XXX import XXX (thanks to the repetitive names), e.g. from actions import ListitAction, ViewAction must become two imports:

    from actions.ListitAction import ListitAction
    from actions.ViewAction import ViewAction
    

    because the classes being imported come from different modules under the actions package.

提交回复
热议问题