

You're doing super(reqboxfileparser, self), but you're passing the inherited class ( reqboxfileparser) as first argument, not the inheriting class.Īs a consequence, Python would try to find a class that reqboxfileparser inherits from which implements what you're looking for you're looking for: f.īut that's not want you want: what you want an ancestor of reqboxfileparserng that implements f that would be reqboxfileparser. Improper super call in inheriting classes: There are two issues at hand here: Super and old-style classes:Ĭlass reqboxfileparser(): does not inherit from object, as a consequence, super(reqboxfileparser, self) will always yield the error: It's been a while since I don't develop classes with inheritance but if I'm not wrong the concepts are right. On the main program I call the method: parsefile("./data/LRCv12.txt") which later calls getfundict() on the second class, but when I try to access f.size() it always fails with TypeError: must be type, not classobj. įills the fundict property with a dict where each element is indexedīy the fun name and each value is an object from the modelįinalloc = super(reqboxfileparser, self).f.size() - 1Īs you can see I have two classes, the first is reqboxfileparser() and the second one is reqboxfileparserng() which inherits from the first one. Ĭlass reqboxfileparserng(reqboxfileparser, object):įh = open(self.importsdir + 'in-uc-objects.csv', 'rb')
Python oop inheritance code#
rest of reqboxfileparser() class code removed. Self.vlog(VERB_MED, "fundict = %s" % (self.fundict)) Self.vlog(VERB_MED, "len(fun) = %d" % (len(self.funlist))) Self.f = mmap.mmap((), 0, access=mmap.ACCESS_READ) Self.file = codecs.open(filename, encoding='utf-8', mode='r') # open(filename, 'r') Here are the classes: class reqboxfileparser(): Rfp = reqboxfileparserng() # Inherits from reqboxfileparser()
