Skip to content

capture_output does not respect trailing semicolon#13940

Merged
Carreau merged 3 commits into
ipython:mainfrom
nfgferreira:main
Feb 22, 2023
Merged

capture_output does not respect trailing semicolon#13940
Carreau merged 3 commits into
ipython:mainfrom
nfgferreira:main

Conversation

@nfgferreira
Copy link
Copy Markdown
Contributor

This change tests whether the Python code inside the %%capture magic ends with a ';'. If it does, the code no longer creates the object that is supposed to store the cell output. If such object already exists, it is deleted.
Please review and suggest changes if you think they can improve the solution. Thanks.

@nfgferreira nfgferreira changed the title Issue #13926 capture_output does not respect trailing semicolon Feb 12, 2023
@akhmerov
Copy link
Copy Markdown
Member

I'm wondering whether the addition should go into capture_output instead. I think it would make sense, and would also enable easier programmatic usage.

@nfgferreira
Copy link
Copy Markdown
Contributor Author

I think it wouldn't work. The decision of showing or not the output comes from the parsing of the Python code in the cell. capture_output is not aware of the cell contents and therefore does not see the semicolon.

@Carreau Carreau added this to the 8.11 milestone Feb 13, 2023
@Carreau
Copy link
Copy Markdown
Member

Carreau commented Feb 13, 2023

That seam reasonable.

I'll still think about it a bit, and mere later if no-one has objections.

@Carreau Carreau merged commit 75ecfe9 into ipython:main Feb 22, 2023
@Carreau
Copy link
Copy Markdown
Member

Carreau commented Feb 22, 2023

Thanks !

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.

3 participants