On 11.09.2013 23:15, Ethan Furman wrote: > On 09/11/2013 01:41 PM, Markus Rother wrote: >> >>> () == [] >> 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).
While trying to do it, I learned that its not the right way to do it. However, I was not satisfied with the fact, that there is no built in pure function for operations on primitives. Such that >>> def get_do_stuff (fn): ... def do_stuff(x,y): ... return fn(x,y) ... return do_stuff I understand that python is not a functional language, but it frustrates me at times. Markus -- https://mail.python.org/mailman/listinfo/python-list