"模块对象没有属性"自定义类python

时间:2017-11-19 08:32:40

标签: python nested

这是我的mydatatype.py

class answer(object):
    answer_start = 0
    text = ""
    def set(self,answer_start,text):
        self.answer_start = answer_start
        self.text = text



class quas(object):
    question = ""
    answers = answer()
    def set(self,question,answers):
        self.question = question
        self.answers = answers

class textandquas(object):
    context = ""
    qas = quas()
    def set(self,context,qas):
        self.context = context
        self.qas = quas()

class paragraph(object):
    content = []

这是我的控制台代码:

import mydatatype as mdt
a = mdt.quas()

错误发生了。它发生在quas()textandquas()answer()paragraph()不受影响的情况下。我相信这是与python class-in-class相关的一些错误。 有没有办法在不嵌套类声明的情况下将类放在另一个类中? 先谢谢你。

0 个答案:

没有答案