nikitakit / hydrogen-python

Python-specific plugin for hydrogen. Make Python coding in the Atom editor even more interactive!
https://atom.io/packages/hydrogen-python
MIT License
54 stars 20 forks source link

Feature Request: Expandable/Explorable values #11

Open airdrik opened 6 years ago

airdrik commented 6 years ago

A real nice-to-have would be to be able to browse the inner values of a given variable, so you could expand composite objects to see e.g. the items in a list, the key-value pairs in a dict, or the (public) properties of an object. (this could even be done recursively so that if you have a list of dicts with objects at some of the keys, etc. or just deeply-nested object graphs). This should be done as the user clicks to expand a given variable (or property/sub-item thereof), so you shouldn't need to worry about cycle detection or anything like that.

I imagine this working/looking something akin to the variable explorers that you'd see in many IDEs or browser dev tools while debugging.

(for a python-based example, I recall there was a suite of tools in the wxPython project which included a PyFilling tool for exploring the current namespace. You can still find the source for those here: https://github.com/wxWidgets/Phoenix/tree/master/wx/py)

kylebarron commented 6 years ago

This already exists for Hydrogen, albeit not in a separate variable explorer.

from IPython.display import JSON
JSON(list)
JSON(dict)

image

airdrik commented 6 years ago

Right, I knew about that; I should have mentioned that I'd like this specifically in the Variable Explorer, thus bypassing the need to evaluate (or json-convert) each variable to be able to explore its contents.

nikitakit commented 6 years ago

This would definitely be great to have!

There are some questions to think through for the UI though, since hydrogen is a separate process and doesn't automatically have access to Python variables. The current approach of sending over all variable info after every command works fine for small metadata like type/size, but another approach needs to be taken for exploring the full datastructure.

The UI for this feature also needs to be considered. That's actually the main blocker from my end: I'm primarily a Python programmer and to the extend I do web work it's either semi-static HTML or algorithms/networking in pure javascript. Unfortunately the wxPython project you linked isn't using web technologies for the UI, so I'll need some helping getting UI in place for a feature like this. PRs are always welcome!

airdrik commented 6 years ago

I linked the wsPython project for a pure python example, realizing that it wouldn't be directly translatable. Perhaps a better example would be to look at how Hydrogen handles the JSON display.

I'm kind of in the same boat as I know python but not javascript/node.js/hydrogen.