Language design

Ethan Furman ethan at stoneleaf.us
Wed Sep 11 17:15:20 EDT 2013


On 09/11/2013 01:41 PM, Markus Rother wrote:
>
>      4. As has been mentioned already, some built-in functions do magic
>      stuff behind the scenes:

That's why they're called magic methods.  ;)


>      >>> () == []
>      False
>
>      But:
>
>      >>> bool(().__eq__([]))
>      True

This is not a trap, this is simply the wrong way to do it.  The magic methods (aka dunder methods) are there for Python 
to call, not you (except under special circumstances, such as when writing your own dunder methods).

--
~Ethan~



More information about the Python-list mailing list