<div dir="ltr">You should contribute that to PyExt(<a href="https://github.com/kirbyfan64/pyext">https://github.com/kirbyfan64/pyext</a>). I'd love to have it there.</div><div class="gmail_extra"><br><br><div class="gmail_quote">

On Fri, Feb 21, 2014 at 7:45 PM, Mathias Panzenböck <span dir="ltr"><<a href="mailto:grosser.meister.morti@gmx.net" target="_blank">grosser.meister.morti@gmx.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Am 2014-02-21 23:05, schrieb Andrew Barnert:<div class=""><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
While we're discussing crazy ideas inspired by a combination of a long-abandoned PEP and Haskell idioms (see the implicit lambda thread), here's another: arbitrary infix operators:<br>
<br>
     a `foo` b == foo(a, b)<br>
<br>
</blockquote>
<br></div>
If you really want to you could do this:<br>
<br>
        class infix(object):<br>
                __slots__ = '__call__',<br>
        <br>
                def __init__(self,func):<br>
                        self.__call__ = func<br>
        <br>
                def __ror__(self,arg1):<br>
                        return infix2(self.__call__, arg1)<br>
        <br>
        class infix2(object):<br>
                __slots__ = 'func', 'arg1'<br>
        <br>
                def __init__(self,func,arg1):<br>
                        self.func = func<br>
                        self.arg1 = arg1<br>
        <br>
                def __call__(*args,**kwargs):<br>
                        self, args = args[0], args[1:]<br>
                        return self.func(self.arg1,*args,**<u></u>kwargs)<br>
                <br>
                def __or__(self,arg2):<br>
                        return self.func(self.arg1,arg2)<br>
        <br>
        @infix<br>
        def foo(a,b):<br>
                return a + b<br>
        <br>
        print "egg" |foo| "spam"<div class="HOEnZb"><div class="h5"><br>
<br>
______________________________<u></u>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/<u></u>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/<u></u>codeofconduct/</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Ryan<div><div>If anybody ever asks me why I prefer C++ to C, my answer will be simple: "It's becauseslejfp23(@#Q*(E*EIdc-SEGFAULT. Wait, I don't think that was nul-terminated."</div>

</div><div><br></div></div>
</div>