GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com โ€” Add --pager to %whos and %history ๐Ÿค–๐Ÿค– by wolfgang-aura ยท Pull Request #15408 ยท ipython/ipython

Conversation

@wolfgang-aura

@wolfgang-aura wolfgang-aura commented Sep 28, 2026

Copy link
Copy Markdown

Closes #9891. ๐Ÿค–๐Ÿค–

%whos and %history print straight to the console, so checking the namespace or recent input leaves a long listing in the scrollback. This adds a --pager flag to both, following @takluyver's suggestions on the issue: a new option on each existing magic, routed through IPython.core.page.page() instead of a pager subprocess.

  • %history --pager writes into a StringIO instead of sys.stdout and passes the text to page.page(). Combining it with -f FILENAME raises a UsageError, since the output cannot go to both.
  • %whos --pager strips the flag, runs the usual listing under redirect_stdout, and pages the captured text. The other %whos arguments (type filters) still apply.
  • page.page() keeps its usual behaviour: short output is printed as normal, and it handles $PAGER and Windows.

A whatsnew entry is in docs/source/whatsnew/pr/magics-pager-option.rst, and the %whos docstring mentions the flag. Size: 5 files, 68 lines added, 2 removed.

Tests

test_history_magic_pager in tests/test_history.py and test_whos_pager in tests/test_magic.py patch page.page, check that the output reaches it rather than stdout, and check the --pager -f refusal. Both use the new flag, so neither can pass without this change. The patch was written and checked on Windows 11 with Python 3.14.3 only; this PR's CI is the check on other platforms.

Alternatives not taken

A generic decorator that adds --pager to every magic. takluyver advised doing it only in the magics where it makes sense, and a decorator would have to reach into each magic's argument parsing.

AI disclosure

This change was written with AI assistance: Claude (claude-opus-5-5) wrote the patch and a second Claude (claude-opus-5-5) instance reviewed it, running under the Mailman harness. ๐Ÿค–๐Ÿค–

๐Ÿค– Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@wolfgang-aura @claude
Add --pager to %whos and %history ๐Ÿค–๐Ÿค–
c3945b8
Closes ipython#9891.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

feature request: redirect magic's result to pager

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@wolfgang-aura
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 โ€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร—600. No cookies required.