Re:A trick to have arbitrary infix operators in Python
by cttet on Tuesday January 25, 2022 @11:25PM
(#30081689)
not quite, since `a + b != b + a` feels a bit weird.
[ Parent
| on HN ]
Re:A trick to have arbitrary infix operators in Python
by dataflow on Tuesday January 25, 2022 @11:27PM
(#30081709)
I think you missed the other thread... https://news.ycombinator.com/item?id=30081517
Re:A trick to have arbitrary infix operators in Python
by cttet on Tuesday January 25, 2022 @11:42PM
(#30081805)
(a, b) would make more sense if then.
Jokes aside, + also quite break the reading flows of the string such as
user_name + ": " + attr1 + "| " + attr2 + "\n"
is more difficult to parse by eyeball for me then
concat(user_name, ": ", attr1, "| ", attr2, "\n")
Re:A trick to have arbitrary infix operators in Python
by dataflow on Tuesday January 25, 2022 @11:47PM
(#30081842)
I mean sure, but the fact that you had to write 6 strings to illustrate this should tell you something, right?
This
user_name + ": " + attr1
is easier to eyeball than concat(user_name, ": ", attr1)