[Python-ideas] Infix application of binary functions
Chris Rebert
pyideas at rebertia.com
Thu Jul 22 01:41:11 CEST 2010
> On 07/22/2010 01:17 AM, Chris Rebert wrote:
>> On Wed, Jul 21, 2010 at 3:37 PM, Dag Odenhall<dag.odenhall at gmail.com>
>> wrote:
>>> It could help readability if binary (arity of 2) functions could be
>>> applied infix with some syntax. For example, borrowing from Haskell, the
>>> backtick could be reintroduced for this purpose.
>>>
>>> Good examples for this are isinstance and hasattr:
>>>
>>> if some_object `isinstance` Iterable:
>>> ...
>>> elif some_object `hasattr` '__iter__':
>>
>> Already proposed (by me) and rejected by the BDFL:
>>
>> http://mail.python.org/pipermail/python-ideas/2007-January/000054.html
>>
On Wed, Jul 21, 2010 at 4:33 PM, Mathias Panzenböck
<grosser.meister.morti at gmx.net> wrote:
> Then what about:
<snip>
> obj *isinstance Iterable
How would the parser distinguish that from multiplication?
> or
> obj isinstance? Iterable
That would look odd for non-interoggative binary functions:
z = x cartesianProduct? y
> These don't use the backtick charackter (wich on some setups even is a
> unicode char not from 7bit ascii).
Not using backtick definitely makes the proposal more viable.
(Personally I <3 backtick though.)
Cheers,
Chris
More information about the Python-ideas
mailing list