Skip to content
Advertisement

AttributeError: ‘int’ object has no attribute item

The code is:

JavaScript

Why does it happen? I’ve been wasting hours searching for an solution, no result.

The error occurs at:

JavaScript

Advertisement

Answer

Are you thinking something like this?

JavaScript

Or if you want to use CreateNew as a class method you can call without creating a new object, you can do it like this

JavaScript

But using class methods (or static methods) is unusual in Python. And perhaps a bit advanced in this context. This approach is more common in for example C#.

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