TypeError: super(type, obj): obj must be an instance or subtype of type 该错误的一次处理
我在写maya类的时候遇到,版本python2.7
- folder
- lib
- mayaclass.py
- base类
- A(base)类
- ui.py
- mayaclass.py
- lib
其中A继承base
ui.py文件中内容
#python2.7
import imp
from folder.lib import mayaclass
imp.reload(mayaclass)
from folder.lib.mayaclass import *
为了测试需要,我在控制台执行
import imp
from folder.lib import mayaclass
imp.reload(mayaclass)
from folder.lib.mayaclass import *
from folder import ui
imp.reload(ui)
此时在控制台建立对象会报错
A()
TypeError: super(type, obj): obj must be an instance or subtype of type
意思是说没有继承关系
可能原因是 文件中再次导入了一遍mayaclass 中的类
导致内存中两份类不一样,建立子类失败
如果在控制台中去掉文件中导入的那部分就神奇的不会报错
import imp
from folder.lib import mayaclass
imp.reload(mayaclass)
from folder.lib.mayaclass import *
#from folder import ui # 文件中再次导入了一遍mayaclass 中的类,导致出现不一致的情况
#imp.reload(ui)
如果换成python3.7也会报错,但是将
super(类名,self).__init__()
替换成
super().__init__()
就不会报错
哪个大神能深入解答原因,是不是reload导致的
TypeError: super(type, obj): obj must be an instance or subtype of type 该错误的一次处理相关推荐
- TypeError: super(type, obj): obj must be an instance or subtype of type这个问题怎么处理?
TypeError: super(type, obj): obj must be an instance or subtype of type这个问题怎么处理? 这个错误通常发生在使用super()函 ...
- Python提示 TypeError: super(type, obj): obj must be an instance or subtype of type问题
Python提示 TypeError: super(type, obj): obj must be an instance or subtype of type问题 简述问题 在工作中有一天将debu ...
- TypeError: super(type, obj): obj must be an instance or subtype of type
问题 今天学习<Python Web 开发实战>自定义转换器这一小节,书中有段代码如下: class ListConverter(BaseConverter):def __init__(s ...
- 成功解决TypeError: super(type, obj): obj must be an instance or subtype of type
super(Graphnet, self).init()改为 super().init()
- Python报错 TypeError: super(type, obj): obj must be an instance or subtype of type
今天在Spyder里用BeautifulSoup的时候跑代码报这个TypeError. 遇到这个问题之后在网上搜了一下也不知道怎么解决,结果在Spyder里重启Ipython内核之后,就没有报错能顺利 ...
- Flutter type ‘Future<bool>‘ is not a subtype of type ‘bool‘ in type cast
这个问题是我在使用flutter shared_preferences的时候,自己默认写了几个存储和读取的字段函数,然后出错了 问题在! 我使用的时候非常耿直 如图 getUserNameInput函 ...
- python 调用super()初始化报错“TypeError: super() takes at least 1 argument”
在python中有如下代码: class father():def __init__(self,age):self.age = age;def get_age(self):print(self.age ...
- python 函数继承调用super()初始化报错“TypeError: super() takes at least 1 argument”
在python中有如下代码: class father():def __init__(self,age):self.age = agedef get_age(self):print(self.age) ...
- #报错解决#TypeError Failed to execute ‘readAsText‘ on ‘FileReader‘ parameter 1 is not of type ‘Blob‘
问题描述 在实现需求:批量下载的时候,返回的数据类型设置为blob $http({method: 'post',url: dataurl,data: bodyParam,headers: { 'Con ...
最新文章
- webstorm2018修改运行web page端口号,并且让web在本地局域网内用IP访问
- Rancher Labs赋能合作伙伴抢滩容器市场
- 输入一个正整数,求它各位数的数字之和
- Byte和bit的区别?
- C++友元函数访问私有成员
- python搭建自动化测试平台_如何用python语言搭建自动化测试环境
- 爬虫篇 | 快速入门selenium(十一)
- python如何输入空行_在python中,如何在接受用户输入时跳过空行?
- sicktim571操作手册_SICK激光传感器TIM310操作说明书
- 【Java】数据结构——栈(图文)
- 清北学堂2019.5.3
- 【谷粒学院】项目总结
- 微星刀锋 无法进入bios_微星MPG X570 GAMING EDGE WIFI刀锋板主板BIOS设置u盘启动教程...
- unity 给图片边缘_Unity 截图选择框,中间全透明,边缘半透明
- python获取网页数据判断并提交_python3爬虫无法通过网页内容判断存在与否?
- win12 修改dns脚本
- OneNote for Windows10 闪退 的解决办法
- 有些疑问,阿里云到底是做啥子的呢?
- java实现excel打印_java实现 excel 打印 问题
- 今日收获 可以点击的标签 鼠标悬浮 小手图标
热门文章
- python熊猫图案_Python熊猫:您可能不知道的技巧和功能
- LifecycleException: Protocol handler start failed 端口占用异常
- 用简单C语言编程数码管时钟,成功C DIY 单片机(3)51单片机直接实现最简单的时钟...
- ESP8266及数码管的网络时钟
- 有代做计算机毕业设计的吗,基于vue的
- 使用本地服务器打开html文件
- 公司党建在线视频学习
- 未来stem课程的发展之路
- 报录比35:1,北京航空航天大学22考研还没报完名就这么高!
- 山东省教师职称评定取消计算机,2019年山东教师职称评审通知来了,正高级按岗核定,不再限指标...