我在写maya类的时候遇到,版本python2.7

  • folder

    • lib

      • mayaclass.py

        • base类
        • A(base)类
      • ui.py

其中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 该错误的一次处理相关推荐

  1. 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()函 ...

  2. 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 ...

  3. TypeError: super(type, obj): obj must be an instance or subtype of type

    问题 今天学习<Python Web 开发实战>自定义转换器这一小节,书中有段代码如下: class ListConverter(BaseConverter):def __init__(s ...

  4. 成功解决TypeError: super(type, obj): obj must be an instance or subtype of type

    super(Graphnet, self).init()改为 super().init()

  5. Python报错 TypeError: super(type, obj): obj must be an instance or subtype of type

    今天在Spyder里用BeautifulSoup的时候跑代码报这个TypeError. 遇到这个问题之后在网上搜了一下也不知道怎么解决,结果在Spyder里重启Ipython内核之后,就没有报错能顺利 ...

  6. Flutter type ‘Future<bool>‘ is not a subtype of type ‘bool‘ in type cast

    这个问题是我在使用flutter shared_preferences的时候,自己默认写了几个存储和读取的字段函数,然后出错了 问题在! 我使用的时候非常耿直 如图 getUserNameInput函 ...

  7. 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 ...

  8. 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) ...

  9. #报错解决#TypeError Failed to execute ‘readAsText‘ on ‘FileReader‘ parameter 1 is not of type ‘Blob‘

    问题描述 在实现需求:批量下载的时候,返回的数据类型设置为blob $http({method: 'post',url: dataurl,data: bodyParam,headers: { 'Con ...

最新文章

  1. webstorm2018修改运行web page端口号,并且让web在本地局域网内用IP访问
  2. Rancher Labs赋能合作伙伴抢滩容器市场
  3. 输入一个正整数,求它各位数的数字之和
  4. Byte和bit的区别?
  5. C++友元函数访问私有成员
  6. python搭建自动化测试平台_如何用python语言搭建自动化测试环境
  7. 爬虫篇 | 快速入门selenium(十一)
  8. python如何输入空行_在python中,如何在接受用户输入时跳过空行?
  9. sicktim571操作手册_SICK激光传感器TIM310操作说明书
  10. 【Java】数据结构——栈(图文)
  11. 清北学堂2019.5.3
  12. 【谷粒学院】项目总结
  13. 微星刀锋 无法进入bios_微星MPG X570 GAMING EDGE WIFI刀锋板主板BIOS设置u盘启动教程...
  14. unity 给图片边缘_Unity 截图选择框,中间全透明,边缘半透明
  15. python获取网页数据判断并提交_python3爬虫无法通过网页内容判断存在与否?
  16. win12 修改dns脚本
  17. OneNote for Windows10 闪退 的解决办法
  18. 有些疑问,阿里云到底是做啥子的呢?
  19. java实现excel打印_java实现 excel 打印 问题
  20. 今日收获 可以点击的标签 鼠标悬浮 小手图标

热门文章

  1. python熊猫图案_Python熊猫:您可能不知道的技巧和功能
  2. LifecycleException: Protocol handler start failed 端口占用异常
  3. 用简单C语言编程数码管时钟,成功C DIY 单片机(3)51单片机直接实现最简单的时钟...
  4. ESP8266及数码管的网络时钟
  5. 有代做计算机毕业设计的吗,基于vue的
  6. 使用本地服务器打开html文件
  7. 公司党建在线视频学习
  8. 未来stem课程的发展之路
  9. 报录比35:1,北京航空航天大学22考研还没报完名就这么高!
  10. 山东省教师职称评定取消计算机,2019年山东教师职称评审通知来了,正高级按岗核定,不再限指标...