I get obj1 from db1
I know for sure that this is an object of class x , but I cannot access the methods of this class.
How to convert obj1 to class x to access its methods.
obj1.metod1() class code snippet
class prodObject(object): def __init__(self, prodName, element=None): self.prodname = prodName self.elements = [] if element is not None: self.elements.append(element) def getelEmentInProducts(self): result = self.elements return result snippet where the error crashes
def getelEment(name): result = [] for inst in database2: promData = database2[inst] if promData.getelEmentInProducts().__contains__ (name): if not result.__contains__(promData): result.append (promData) return result fragment of code which calls this method
if __name__ == "__main__": gdb = database.getelEment ('a3') error code
if promData.getelEmentInProducts () .__ contains__ (name):
AttributeError: type object 'object' has no attribute 'getelEmentInProducts'
The whole problem is this line.
if promData.getelEmentInProducts().__contains__ (name): or rather, promData for some reason has a class object and should be prodObject
database2(and still in the code the indents are incorrect, the code was formatted inaccurately) - andreymal