Skip to content

Delay flushing softspace until after cell finishes - #1662

Merged
minrk merged 3 commits into
ipython:masterfrom
bfroehle:flush_softspace
Apr 26, 2012
Merged

Delay flushing softspace until after cell finishes#1662
minrk merged 3 commits into
ipython:masterfrom
bfroehle:flush_softspace

Conversation

@bfroehle

Copy link
Copy Markdown
Contributor

Delay flushing softspace (i.e., printing a new line if sys.stdout.softspace is True) until after cell finishes executing.

This changes the behavior from

In [1]: print 1,; print 2
1
2

to the more expected

In [1]: print 1,; print 2
1 2

Includes a test. Python 3 remove the notion of softspace, so the test limits itself to Python 2 only.

Closes #1512.

Fixes the behavior of print statements with trailing commas to suppress
new-lines:

    In [1]: print 1,; print 2
    1 2
@minrk

minrk commented Apr 25, 2012

Copy link
Copy Markdown
Member

Since these are the only two calls to run_code, and neither one should flush softspace, why not just remove that call from run_code entirely, in favor of its new location in run_cell, rather than adding a new arg that should always be False?

@bfroehle

Copy link
Copy Markdown
Contributor Author

There does appear to be one other use of run_code in zmq.ipkernel. Nonetheless I agree with your suggestion and have added a new commit.

@minrk

minrk commented Apr 26, 2012

Copy link
Copy Markdown
Member

Thanks! Looks good to me, then.

The run_code() call in zmq.ipkernel is actually a bug, and will be removed by PR #1630.

minrk added a commit that referenced this pull request Apr 26, 2012
move flushing softspace to run_cell from run_code

called only once per cell

closes #1512
@minrk
minrk merged commit 538bc5a into ipython:master Apr 26, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
move flushing softspace to run_cell from run_code

called only once per cell

closes ipython#1512
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.

print stuff, should avoid newline

2 participants