Skip to content
Advertisement

Get __repr__ to return string that has same value when passed to eval?

I don’t fully understand what is going on here. Why does the returned string from repr evaluate to False? If anyone can expand on what I’m not understanding here, that would be really appreciated.

JavaScript

Advertisement

Answer

You also need to define an __eq__ method to define how a Bag is equal to another Bag:

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