Python Object-Oriented Python Advanced Objects Subclassing Built-ins

Son-Hai Nguyen
Son-Hai Nguyen
1,655 Points

What 'item' in 'return self[item]' stands for?

In return self[item], what does the item stand for? Is it stand for keys we put in our dictionary?

And I see this item gave results which are pretty similar to:

for key, value in kwargs.items():
            setattr(self, key, value)

Are they the same?

Thank you.

1 Answer

.items() method is used to return the list with all dictionary keys with values.

Son-Hai Nguyen
Son-Hai Nguyen
1,655 Points

So self[item] has the same function hasnt it?