Skip to content
Advertisement

AttributeError: ‘Catalog’ object has no attribute ‘component’

I got this code written

But I get always error which says: AttributeError: ‘Catalog’ object has no attribute ‘component’. the problem is that I cannot see where is the problem. Is there something wrong (maybe indentation?). Thanks

Here is snippet where it finds error

Full error code

Advertisement

Answer

The trace back shows you the issue.

for key, component in self.component.items():

In this line self refers to Catalog class and as the error tells you it doesnt have any attribute called component. In your init method you define an attribute called components

So likley you have made a typo and should change

for key, component in self.component.items():

to

for key, component in self.components.items():

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement