织梦CMS - 轻松建站从此开始!

欧博ABG官网-欧博官方网址-会员登入

Attrib欧博注册uteError: 'super' object has no

时间:2025-12-24 03:26来源: 作者:admin 点击: 2 次
You have a few issues here. Firstly there was an indentation error for the parent do_something definition. This meant that it was defined as a functio

You have a few issues here. Firstly there was an indentation error for the parent do_something definition. This meant that it was defined as a function in and of itself, rather than being a method of the class Parent.

Secondly, class methods should usually have self as their first parameter, as when they are called, the object that they refer to is passed as the first variable.

Thirdly, when you call super() you do not need to specify what the super is, as that is inherent in the class definition for Child.

Below is a fixed version of your code which should perform as you expect.

class Parent: def __init__(self): pass def do_something(self, some_parameter, next_parameter): if type(some_parameter) is not int: raise AttributeError("Some message") if type(next_parameter) is not int: raise AttributeError("Some message") class Child(Parent): def __init__(self): super(Parent).__init__() def do_something(self, some_parameter, next_parameter): super().do_something(some_parameter, next_parameter) return some_parameter + next_parameter test = Child() test.do_something(2, 2)

(责任编辑:)
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:
发布者资料
查看详细资料 发送留言 加为好友 用户等级: 注册时间:2025-12-24 19:12 最后登录:2025-12-24 19:12
栏目列表
推荐内容