Waaat :D. This is so nice. I used to use python-ls[0] for similar, but something about it that I can't recall broke for me and it's no longer maintained. Adding to my debugging arsenal which primarily consists of snoop[1] and pdbpp. Only thing I'd like for wat now is maybe an ipy widget for even easier object exploration in Jupyter.
Ah this looks fun! I use "dir" all the time with python, and find it more useful than official documentation in some cases where documentation is not great.
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.
And if you use IPython, you can use the ? shorthand, too:
In [1]: int?
Init signature: int(self, /, *args, **kwargs)
Docstring:
int([x]) -> integer
int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments
are given. If x is a number, return x.__int__(). For floating point
numbers, this truncates towards zero.
[...]
1. Write the program skeleton 2. Put an import pdb;
pdb.set_trace() whereever I need to fill out next 3. Once I hit the breakpoint, type 'interact' 4. Start coding in the debugger. 4a. For small functions write in a scratch pad, test against another python console, then paste into the current debugger. 4b. For network calls, save the inputs and outputs. Toss a decorator on some functions to log the inputs and outputs to files, and cool we already have some proto test data. 4c. For documentation, call help() on the variable or method or module.
Comments (92) 30 threads
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.
1. Write the program skeleton
2. Put an import pdb; pdb.set_trace() whereever I need to fill out next
3. Once I hit the breakpoint, type 'interact'
4. Start coding in the debugger.
4a. For small functions write in a scratch pad, test against another python console, then paste into the current debugger.
4b. For network calls, save the inputs and outputs. Toss a decorator on some functions to log the inputs and outputs to files, and cool we already have some proto test data.
4c. For documentation, call help() on the variable or method or module.
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.
All comments shown.
Couldn't load more comments. Check your connection and try again.