Here is my 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 = []
Here is my console code:
import mydatatype as mdt
a = mdt.quas()
And the error happens. It happens with quas()
and textandquas()
, answer()
and paragraph()
are not affected. I believe this is some error related to python class-in-class.
Are there any way that I can put a class in another class like that without nesting the class declaration ?
Thank you in advanced.
mydatatype.pyc
file (note the c at the end) delete it. Also, are you using iPython in some way (Spyder/Enthought Canopy for example)?Traceback (most recent call last): File "<ipython-input-619-c5acadbd7098>", line 1, in <module> a = mdt.quas() AttributeError: 'module' object has no attribute 'quas'
.
. When it asks, click yes to restarting the kernal. Then try running your code.