Hacker News new | past | comments | ask | show | jobs | submit login

It's a hack using a single character binary operator and the way it's implemented for the type that serves as the main “operator” on between the paired use.

> Where is this documented

Insofar as it is, on the page linked. The underlying operator overloading mechanism that his leverages is documented in the official Python docs.




OHHH. Looking at the Infix class carefully I realize it's not actually |add| as a single operator but using the right or __ror__ to partially apply the function, then using the left or __or__ to fully apply it. Wrapping it up in a decorator class is really neat!




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: