Bash-like pipes in Python

Christian Gollwitzer auriocus at gmx.de
Wed Mar 16 11:16:19 EDT 2016


Am 16.03.16 um 16:09 schrieb Joel Goldstick:
> On Wed, Mar 16, 2016 at 10:57 AM, Steven D'Aprano <steve at pearwood.info>
> wrote:
>> py> from operator import mul
>> py> "abcd12345xyz" | Filter(str.isdigit) | Map(int) | Reduce(mul)
>> 120
>>
>> This is interesting, but the part I'm missing is the use of the Pipe
> symbol '|' in python.  Can you elaborate


It's an overloaded "or" operator

	def __ror__(self, iterable): ....

	
Christian




More information about the Python-list mailing list