[Python-ideas] Function composition (was no subject)

Steven D'Aprano steve at pearwood.info
Sun May 10 05:01:46 CEST 2015


On Sat, May 09, 2015 at 10:41:24PM +0200, Gregory Salvan wrote:
> pipeline operator may be confusing with bitwise operator.
> In this case :
> eggs = arg | spam | cheese
> 
> Is eggs a composed function or string of bits ?

Or a set?

I think it is okay to overload operators and give them different 
meanings:

z = x + y

Is z a number, a string, a list, a tuple? Something else?

In practice, we rely on sensible names or context to understand 
overloaded operators, if you see

foo = search | grep | log | process
it = (foo(x) for x in data)
run(it)

it should be fairly obvious from context that foo is not a set or string 
of bits :-)



-- 
Steve


More information about the Python-ideas mailing list