TypeError: got multiple values for argument

前端 未结 7 2350
忘掉有多难
忘掉有多难 2020-11-28 06:13

I read the other threads that had to do with this error and it seems that my problem has an interesting distinct difference than all the posts I read so far, namely, all the

7条回答
  •  孤独总比滥情好
    2020-11-28 06:19

    This also happens if you forget selfdeclaration inside class methods.

    Example:

    class Example():
        def is_overlapping(x1, x2, y1, y2):
            # Thanks to https://stackoverflow.com/a/12888920/940592
            return max(x1, y1) <= min(x2, y2)
    

    Fails calling it like self.is_overlapping(x1=2, x2=4, y1=3, y2=5) with:

    {TypeError} is_overlapping() got multiple values for argument 'x1'

    WORKS:

    class Example():
        def is_overlapping(self, x1, x2, y1, y2):
            # Thanks to https://stackoverflow.com/a/12888920/940592
            return max(x1, y1) <= min(x2, y2)
    

提交回复
热议问题