Readit News logoReadit News
igrek51 commented on Show HN: Wat – Deep inspection of Python objects   github.com/igrek51/wat... · Posted by u/igrek51
Tomte · a year ago
Wrong direction: you‘d „pipe“ wat through the object. Although TiddlyWiki users might feel right at home.
igrek51 · a year ago
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"
igrek51 commented on Show HN: Wat – Deep inspection of Python objects   github.com/igrek51/wat... · Posted by u/igrek51
igrek51 · a year ago
"import wat" would be great, but Python has some restrictions about modules not being callable. That's why I ended up with longer `from wat import wat`. Not sure but maybe this would be more convenient `import wat; wat.wat / object`
igrek51 · a year ago
Thank you all, I learned from you that it's possible to have a callable module. Although `sys.modules[__name__] = wat` looks like a black magic and I'm a bit afraid of locking out to other importable things in this package, I think I'll go for it.
igrek51 commented on Show HN: Wat – Deep inspection of Python objects   github.com/igrek51/wat... · Posted by u/igrek51
enriquto · a year ago
> from wat import wat

Given the cool nature of this project, I'm surprised they don't offer simply "import wat" with identical usage syntax. Thus inviting curious users to wat/wat in order to discover the trick...

igrek51 · a year ago
"import wat" would be great, but Python has some restrictions about modules not being callable. That's why I ended up with longer `from wat import wat`. Not sure but maybe this would be more convenient `import wat; wat.wat / object`
igrek51 commented on Show HN: Wat – Deep inspection of Python objects   github.com/igrek51/wat... · Posted by u/igrek51
alkh · a year ago
It important to remind everyone that you can already do something similar via the build-in function help(). For example, if I run help({1}) I get the documentation for a set, running help(set.add) gives the documentation for the add() method, etc. You can even preview objects that you haven't imported by using strings(ex. running help('numpy.ndarray') will correctly give you the documentation, provided numpy is installed in your current python environment). It's pretty helpful and doesn't require installing anything extra
igrek51 · a year ago
You're completely right. `dir()` does the same in terms of functionality. In fact, my tool makes use of `dir` under the hood. I just wanted to make it more readable, and to combine `dir`, `type`, `repr`, `len`, `inspect`, etc. into one easily accessible place.
igrek51 commented on Show HN: Wat – Deep inspection of Python objects   github.com/igrek51/wat... · Posted by u/igrek51
fuzztester · a year ago
just so that it is clear for everyone, including newbies here, does the insta-load code snippet work like this:

the author has encoded the wat module's source code into base64. the snippet shown decodes that back into python code, and then executes it on the fly, thus having the same effect as importing the wat module in the normal python way?

igrek51 · a year ago
Yes, that has the same effect as installing the package. So if you feel uncomfortable, you can either install the pip package (and of course review the installed code) or review the decoded string before executing it. It's not that obfuscated anyways, it's still quite readable.
igrek51 commented on Show HN: Wat – Deep inspection of Python objects   github.com/igrek51/wat... · Posted by u/igrek51
languagehacker · a year ago
This is interesting. I'm wondering what compelled the author to use the division magic method for arguments instead of the more intuitive and commonly used approach to passing parameters.
igrek51 · a year ago
It's the parentheses that drove me crazy. As people already noted, it's for faster typing, at the cost of the division magic as you noted. If it's more familiar to you, it works with `wat(object)` syntax as well.
igrek51 commented on fpick – Interactive File Picker   github.com/igrek51/fpick... · Posted by u/igrek51
igrek51 · 2 years ago
Interactive file picker to traverse through directories tree in a terminal

u/igrek51

KarmaCake day144April 27, 2023View Original