News for hackers. Stuff that matters.
Re:Show HN: Wat – Deep inspection of Python objects by Retr0id on Thursday July 25, 2024 @04:07PM (#41072813)
I'm normally a big fan of python operator overload hacks, but why are we doing `wat / foo` instead of just `wat(foo)` ?
Re:Show HN: Wat – Deep inspection of Python objects by JulianChastain on Thursday July 25, 2024 @04:41PM (#41073143)
`wat(foo)` also works. The author says he implmented the `wat / foo` syntax to allow you to more quickly use wat by avoiding parentheses
Re:Show HN: Wat – Deep inspection of Python objects by contravariant on Thursday July 25, 2024 @06:15PM (#41073961)
Probably so you can run a big complicated formula in the REPL and easily prepend `wat /` to it to inspect what's going on.

Same reason jupyter notebooks allow you to prepend '?' or '??' to inspect a variable (though not expressions, in that respect this syntax is better)

Re:Show HN: Wat – Deep inspection of Python objects by jawns on Thursday July 25, 2024 @08:58PM (#41075013)
I get the reasoning behind it, but the choice of the division operator is still a little weird.

I believe it should be equally possible to overload the bitwise OR operator (|), which, for people used to piping in Unix, is probably more intuitive.

Re:Show HN: Wat – Deep inspection of Python objects by Tomte on Friday July 26, 2024 @01:22AM (#41075967)
Wrong direction: you‘d „pipe“ wat through the object. Although TiddlyWiki users might feel right at home.
Re:Show HN: Wat – Deep inspection of Python objects by auscompgeek on Friday July 26, 2024 @05:41AM (#41077186)
It could override the reverse bitwise or magic method `__ror__`.
Re:Show HN: Wat – Deep inspection of Python objects by igrek51 on Friday July 26, 2024 @06:47AM (#41077523)
Right, that would be a wrong pipe direction. Fun fact: It's already possible to do "wat | foo" or "wat << foo" (if you're more familiar with C++ iostream), it has the same effect as "wat / foo"