jupyterlab-contrib / jupyterlab-variableInspector

Variable Inspector extension for Jupyterlab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] new column in Variable Inspector to show any comment on same line as definition

RGD2 opened this issue · comments

commented

I do data science, and need to be precise. But it's a lot of 'write once' linear script code.

So, I make a concerted effort to comment on the same line as each assignment: typically I'll do this first. The line will have a short phrase saying what the thing is, and will include what units it is in.

Then, I'll typically just name the variable with a three or four letter acronynym formed from that phrase, and the units (slashes replaced with p for 'per'), with an underscore to separate them.

I know this is not 'pythonic', but I don't want long lines full_of_long_variable_names, the equations / calculations are long enough already. We often end up needing to change units for the same variable, so it's easier and clearer to read that code this way, with relatively terse variables as mnemonics, but including the units.

If there's any confusion about what a variable is, jumping to where it was defined and reading the comment clears it right up.

The feature request is this: Can Variable Inspector include an optional column after the name of the varible, to be populated by whatever string is after a # on the same source code line?

This could be extended to preview of a function's docstring, if included, but only if no comment on the end of the 'def' line.

stretch feature:

  • also translate markdown / latex code in the comment to a pretty display
commented

Nice benefit of this is, if you redefine a variable accidentally, then the 'pretty name' will straight away vanish from the display, which is likely to be noticed.