Currently, Python only has ~ (tilde) in the context of a unary operation (like 
`-`, with __neg__(self), and `+`, __pos__(self)). 
`~` currently calls `__invert__(self)` in the unary context.
I think it would be awesome to have in the language, as it would allow 
modelling along the lines of R that we currently only get with text, e.g.:
smf.ols(formula='Lottery ~ Literacy + Wealth + Region', data=df)
With a binary context for ~, we could write the above string as pure Python, 
with implications for symbolic evaluation (with SymPy) and statistical 
modelling (such as with sklearn or statsmodels) - and other use-cases/DSLs.
In LaTeX we call this `\sim` (Wikipedia indicates this is for "similar to"). 
I'm not too particular, but `__sim__(self, other)` would have the benefits of 
being both short and consistent with LaTeX.
This is not a fully baked idea, perhaps there's a good reason we haven't added 
a binary `~`.  It seems like I've seen discussion in the past. But I couldn't 
find such discussion. And as I'm currently taking some statistics courses, I'm 
getting R-feature-envy again...
What do you think? 
Aaron Hall


_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/GE77ACXLJMLHCTK73MKVKEW47GAVQOHZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to