Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

? (%pdoc), ?? (%psource), and %pfile open in accumulating sidebar tabs named 'Help' instead of displaying inline in output cells #4816

Open
2 tasks
westurner opened this issue Sep 2, 2024 · 6 comments

Comments

@westurner
Copy link

Describe the current behavior
? (%pdoc), ?? (%psource), and %pfile open in accumulating sidebar tabs named 'Help' instead of displaying inline in an output cell

Describe the expected behavior
Display the output of at least %pdoc, %pfile, and %psource as output cells in the notebook and in the .ipynb.

When I run %pfile,%psource in all other notebook implementations including IPython.notebook and Retrolab, they display the output in an output cell in the notebook,
so that when users scroll through the notebook in order, they see the output after the input.

Additional context
A notebook in percent format that also runs as one input cell:

# %%
import pkg_resources
stylesdir = pkg_resources.resource_filename("matplotlib", "mpl-data/stylelib")
!ls {stylesdir}

# %%
%pfile {stylesdir}/dark_background.mplstyle

# %%
%psource {stylesdir}/dark_background.mplstyle
#!cat {stylesdir}/dark_background.mplstyle

# %%
pkg_resources.resource_filename?
?pkg_resources.resource_filename
%pdoc pkg_resources.resource_filename?

# %%
pkg_resources.resource_filename??
??pkg_resources.resource_filename
%psource pkg_resources.resource_filename
  • Does colab produce .ipynb output equivalent to other notebook implementations (e.g. notebook, jupyterlab; and nbformat) given ?, ??, %pdoc, %psource and %pfile (it doesn't have to at all but;) is the output from %psource in the .ipynb like other implementations?

? (%pdoc) and ?? (%psource) are great for showing docstrings in tutorials, but it's frustrating and less accessible to have to click through indistinct 'Help' tabs that accumulate over notebook runs than to display the output inline like all other notebook output.

  • Add a configuration setting to turn off the automatic sidebar output redirection?
@westurner westurner added the bug label Sep 2, 2024
@westurner westurner changed the title ? (%pdoc), ?? (%psource), and %pfile open in accumulating sidebar tabs named 'Help' instead of displaying inline in an output cell ? (%pdoc), ?? (%psource), and %pfile open in accumulating sidebar tabs named 'Help' instead of displaying inline in a output cells Sep 2, 2024
@westurner westurner changed the title ? (%pdoc), ?? (%psource), and %pfile open in accumulating sidebar tabs named 'Help' instead of displaying inline in a output cells ? (%pdoc), ?? (%psource), and %pfile open in accumulating sidebar tabs named 'Help' instead of displaying inline in output cells Sep 2, 2024
@cperry-goog
Copy link

(pasting in from a team member not on github yet!)

This is a decision that was essentially made prior to Jupyter's release, IPython does not treat ? or ?? as an output, it is merely piping an interactive terminal output to the terminal. This is easy to verify by running any ? or ?? query and then printing the Out variable. We have decided to not treat these outputs as the same since in most cases they are transitory, i.e. users typically want to check the pydoc quickly but will rewrite the cell code to be what their true intentions are; but having that pydoc still available as they test their code has proven generally useful for users.

As workarounds, the python help function will print out the pydoc in the cell output. and the inspect package is great for checking source code and other internal intricacies. An added benefit to this workaround is that since it is pure python and not contingent on Jupyter or IPython API implementation the resulting cell outputs will be the consistent across all Python based environments.

@westurner
Copy link
Author

westurner commented Sep 5, 2024 via email

@westurner
Copy link
Author

westurner commented Sep 5, 2024 via email

@westurner
Copy link
Author

westurner commented Sep 5, 2024 via email

@cperry-goog cperry-goog reopened this Sep 5, 2024
@cperry-goog
Copy link

You're right. Tracking this internally at b/364955129

@westurner
Copy link
Author

westurner commented Sep 8, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants