TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Defining new infix operators in Python

23 pointsby alrex021almost 15 years ago

3 comments

pavpanchekhaalmost 15 years ago
I wrote a library to do this a while back: <a href="http://panchekha.no-ip.com:8082/programming/minioperators.html" rel="nofollow">http://panchekha.no-ip.com:8082/programming/minioperators.ht...</a><p>Hope someone finds it useful, though to be honest, I don't think this sort of thing is very commonly useful.
viraptoralmost 15 years ago
Unfortunately this is not a "proper operator". For example, both sides need to be evaluated, so it cannot control the program flow.<p>Still, I really like the <i>inrex</i> module in the last comment. Great extension to the very clumsy <i>re</i>.
rlpbalmost 15 years ago
Clever hack. But this is one of the key differences between Python and Ruby. In Python, you're not <i>supposed</i> to hack the language like this. The benefit is that Python code remains readable without having to understand how the language has been "altered" in each specific project.<p>If you want to do this level of hacking with the language, why not just use Ruby?
评论 #1606575 未加载
评论 #1606872 未加载
评论 #1606249 未加载
评论 #1606535 未加载