Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Neil Cerutti Newsgroups: comp.lang.python Subject: Re: Language design Date: 12 Sep 2013 18:06:44 GMT Organization: Norwich University Lines: 34 Message-ID: References: <522eb795$0$29999$c3e8da3$5496439d@news.astraweb.com> <5230D58E.9020508@markusrother.de> <5230DD68.2080703@stoneleaf.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: individual.net G4FuDkF+XP/vL2OHohb72QYLVrA4+jy8BxO6h18DY5xlXVutW5 Cancel-Lock: sha1:Uq6q4bF+i6IFCBuY+YSMZdWUhao= User-Agent: slrn/0.9.9p1/mm/ao (Win32) Xref: csiph.com comp.lang.python:54072 On 2013-09-12, Markus Rother wrote: > 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. >>> import operator >>> equal = get_do_stuff(operator.eq)(7, 7.0) True -- Neil Cerutti