I do not quite understand how inheritance works in Python.
I use python 3.6.1.
Let say I have a directory structure /a, /b. These two paths described
in main class.
The second class describes additional structure in one of the main
structures, say on /b and it should look like this:
/b/id1
/b/id2
/b/id3
/b/id4
Here is what I try to do:
class mainCL():
def __init__(self):
self.path1 = "/a"
self.path2 = "/b"
class secondCL(mainCL):
def __init__(newID):
self.pathID = self.path2+"/id"+str(newID)
# main part of the script
secondaryStructure = []
mainStructure = mainCL()
for id in range(0,3):
secondaryStructure[id] = secondCL(id+1)
The error message tells that object secondCL does not have attribute path2.
How do I define class secondCL?
How to use attribute from class mainCL in class secondCL?
How to use class secondCL in a right way? Do I need to pass class mainCL
as a parameter?
--
https://mail.python.org/mailman/listinfo/python-list