Wat – Deep inspection of Python objects
WAT Inspector is a Python tool for runtime object inspection, revealing attributes, types, and methods. It can be used without installation or via pip, offering various modifiers for customization.
Read original articleWAT Inspector is a tool designed for deep inspection of Python objects at runtime, allowing users to gain insights into various attributes of unknown objects. The name "WAT" stands for "What?" and it provides information on object types, formatted values, variables, methods, parent types, signatures, documentation, and source code. Users can utilize WAT without installation by executing a code snippet directly in the Python interpreter or by installing it via pip with the command `pip install wat-inspector`. After installation, it can be imported into Python code using `from wat import wat`.
To inspect an object, users can use the division operator, such as `wat / object`, which is equivalent to `wat(object)`. WAT offers several modifiers to customize the inspection process, including `.short` to hide attributes, `.long` for detailed values and documentation, `.dunder` to display dunder attributes, `.code` to reveal source code, `.nodocs` to hide documentation, and `.all` to include all available information. Examples of usage include determining the type of an object, looking up methods, and exploring modules. Additionally, WAT can be used alongside Python's `breakpoint()` for inspecting local variables during debugging. For further details, users can refer to the official documentation.
Related
What Happens When You Put a Database in the Browser?
WebAssembly (Wasm) enhances browser capabilities, enabling high-performance apps like DuckDB for ad-hoc queries and Python environments. DuckDB Wasm boosts performance in interfaces like lakeFS, Evidence, and Count. MotherDuck enables local querying, emphasizing efficient data processing.
Show HN: I made tool that let's you see everything about any website
Web-Check is a free tool by Alicia Sykes, offering website details through URL scans. It requires JavaScript activation. Licensed under MIT, it aids users with website insights.
MDN tool that tells you of security gaps in your website
The website features the HTTP Observatory tool for free website scanning, real-time AI help, resources for web developers, browser compatibility updates, and a community forum. It aims to enhance internet experiences.
Summary of Major Changes Between Python Versions
The article details Python updates from versions 3.7 to 3.12, highlighting async/await, Walrus operator, Type hints, F-strings, Assignment expressions, Typing enhancements, Structural Pattern Matching, Tomllib, and useful tools.
WhatWeb: Next Generation Web Scanner (2021)
WhatWeb is a web scanner on GitHub by Andrew Horton and Brendan Coles. It identifies websites, web technologies, and CMS. With 1800+ plugins, it offers detailed insights on websites.
- Many users find the tool useful for debugging and object inspection, comparing it to existing tools like icecream and snoop.
- Some commenters express surprise at the lack of built-in tools for introspection in Python, highlighting the need for better native debugging options.
- There are requests for additional features, such as integration with Jupyter and a more intuitive usage syntax.
- Concerns are raised about the security implications of executing arbitrary code, emphasizing the need for caution.
- Several users mention their preference for traditional debugging methods or existing libraries, indicating a diverse range of approaches to Python debugging.
I'm also really appreciating the base64 exec hack. All my years in Python I never thought of or came across it until now. I'll totally be using it for some things :).
[0] https://github.com/gabrielcnr/python-ls [1] https://pypi.org/project/snoop/
Surprised there isn't more innovation and new tools like this around python's interactive shell given it's one of the real strong points the language has.
If you never heard about it, scroll to the bottom to https://github.com/gruns/icecream#icecream-in-other-language...
Twenty years ago I wrote an object introspector for Zope ;)
Nowadays, I'm using devtools daily, and icecream and q occasionally. I'll give wat a try.
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...
try:
from wat import wat
except ImportError:
pass
to your $PYTHONSTARTUP file to avoid the cumbersome import.Instead I just installed pry and became a rabid ruby fanboy, but this might get me to give it another go.
see inspection.py in the wat module.
it has this on line 2:
import inspect as std_inspect
> Load it on the fly by pasting this snippet to your Python interpreter
The idea of having a project's readme include a full copy of the project itself as base64'd compressed data is pretty ingenious!
especially for a project like this where you may not have had the foresight to preload it into the environment where you most need it
I mean the number of times I've bumped on json not being able to dump the content of an object is just infuriating given how flexible Python is.
I'm definitely giving this a whirl.
Please don't do this. Exec'ing arbitrary, obfuscated code you just copied from the internet directly in a running environment is such a bad idea it shouldn't even be suggested.
At the very lease please put huge warnings around this section to let people know that it is a horrendously bad idea and they do it at their own peril.
In a previous company I set things up so that when there's an uncaught exception it will automatically start a VSCode debug session and connect to it.
Here's the extension: https://github.com/Timmmm/autodebug/
Unfortunately the Python part of that is not open source but it was only a few lines of code - should be easy to recreate. That repo does contain a C library that does a similar thing.
You might just say "why not just run your program directly with the debugger?" and yeah that is better when you can do it, but I'm working with complicated silicon verification flows that are often several layers of Python and Make, followed by a simulator (e.g. Questa or VCS) that itself loads the library you want to debug. Very difficult to make debugging work through all those layers, but it's quite easy to write some code at the bottom of the stack that says to a debugger "I'm here, debug me!".
One thing I'd like to note, though, is that most engineers (at least around and including myself) would be triggered by the "Insta-load" example of executing base64 encoded (and thus obfuscated) code.
Related
What Happens When You Put a Database in the Browser?
WebAssembly (Wasm) enhances browser capabilities, enabling high-performance apps like DuckDB for ad-hoc queries and Python environments. DuckDB Wasm boosts performance in interfaces like lakeFS, Evidence, and Count. MotherDuck enables local querying, emphasizing efficient data processing.
Show HN: I made tool that let's you see everything about any website
Web-Check is a free tool by Alicia Sykes, offering website details through URL scans. It requires JavaScript activation. Licensed under MIT, it aids users with website insights.
MDN tool that tells you of security gaps in your website
The website features the HTTP Observatory tool for free website scanning, real-time AI help, resources for web developers, browser compatibility updates, and a community forum. It aims to enhance internet experiences.
Summary of Major Changes Between Python Versions
The article details Python updates from versions 3.7 to 3.12, highlighting async/await, Walrus operator, Type hints, F-strings, Assignment expressions, Typing enhancements, Structural Pattern Matching, Tomllib, and useful tools.
WhatWeb: Next Generation Web Scanner (2021)
WhatWeb is a web scanner on GitHub by Andrew Horton and Brendan Coles. It identifies websites, web technologies, and CMS. With 1800+ plugins, it offers detailed insights on websites.