Skip to content

Conversation

@shamrin
Copy link
Contributor

@shamrin shamrin commented Dec 15, 2021

Fixes #5890.

Introduce Image._repr_pretty_ as an alternative to __repr__ for Jupyter notebook environment.

After this change text/plain output in Jupyter notebook will stay the same after re-running the cell:

$ git diff test.ipynb
diff --git a/test.ipynb b/test.ipynb
index f769d4b..4f8ba79 100644
--- a/test.ipynb
+++ b/test.ipynb
@@ -9,7 +9,7 @@
      "data": {
       "image/png": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAGUlEQVR4nGPc62fCQApgIkn1qIZRDUNKAwADRwFfBBwAnwAAAABJRU5ErkJggg==",
       "text/plain": [
-       "<PIL.Image.Image image mode=RGB size=16x16 at 0x1075D8370>"
+       "<PIL.Image.Image image mode=RGB size=16x16>"
       ]
      },
      "execution_count": 1,

@radarhere radarhere changed the title keep IPython/Jupyter text/plain output stable Keep IPython/Jupyter text/plain output stable Dec 15, 2021
@radarhere radarhere mentioned this pull request Jan 18, 2022
@radarhere
Copy link
Member

I've suggested a test for this in shamrin#1

@hugovk hugovk merged commit 0a49ec1 into python-pillow:main Jan 23, 2022
radarhere added a commit to radarhere/Pillow that referenced this pull request Feb 10, 2022
radarhere added a commit to radarhere/Pillow that referenced this pull request Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changing Jupyter plain text output on every cell run

3 participants