[Python-ideas] Infix application of binary functions
Dag Odenhall
dag.odenhall at gmail.com
Thu Jul 22 01:43:08 CEST 2010
tor 2010-07-22 klockan 01:33 +0200 skrev Mathias Panzenböck:
> Then what about:
> obj $isinstance Iterable
> or
> obj $isinstance$ Iterable
> or
> obj *isinstance Iterable
> or
> obj isinstance? Iterable
>
> These don't use the backtick charackter (wich on some setups even is a unicode char not from 7bit
> ascii).
I like the question mark, although it is only useful for predicates. I
haven't considered if infix is useful for anything other than
predicates, though.
Another possibility is a keyword, maybe "of":
obj isinstance of Iterable or obj hasattr of '__iter__'
But better then would be a keyword that already exists and makes sense
for this use. A character such as the question mark is probably best,
just noting the possibility of a keyword for completeness sake.
An example of a non-predicate infix might be str.format:
'Hello {}' str.format? 'World'
Here, the question mark makes less sense.
More information about the Python-ideas
mailing list