ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 21 Apr 2013 00:49:24 +0200Sage in console: newline characters?https://ask.sagemath.org/question/10043/sage-in-console-newline-characters/I like to use sage in a linux console, rather than the notebook interface, simply for speed and convenience. However, I have problems if I want to edit a multi-line statement. For example, suppose I enter:
for i in range(10):
if is_prime(i):
print i
If I want to edit this, or maybe just run it again, when I call it up with the history mechanism, what I see is
for i in range(10):^J if is prime(i):^J print i
This can be very inconvenient if there are lots of short lines. (I can get round this by running sage within GNU screen.) I'm not quite sure how I encourage newlines to be interpreted as, well new lines rather than newline characters, and whether this is a sage, ipython, or console issue.Sat, 20 Apr 2013 01:16:58 +0200https://ask.sagemath.org/question/10043/sage-in-console-newline-characters/Comment by Alasdair for <p>I like to use sage in a linux console, rather than the notebook interface, simply for speed and convenience. However, I have problems if I want to edit a multi-line statement. For example, suppose I enter:</p>
<pre><code>for i in range(10):
if is_prime(i):
print i
</code></pre>
<p>If I want to edit this, or maybe just run it again, when I call it up with the history mechanism, what I see is</p>
<pre><code>for i in range(10):^J if is prime(i):^J print i
</code></pre>
<p>This can be very inconvenient if there are lots of short lines. (I can get round this by running sage within GNU screen.) I'm not quite sure how I encourage newlines to be interpreted as, well new lines rather than newline characters, and whether this is a sage, ipython, or console issue.</p>
https://ask.sagemath.org/question/10043/sage-in-console-newline-characters/?comment=17838#post-id-17838I'm using Sage 5.2 on Ubuntu 12.04. I've not had this problem with previous versions of Sage. It does seem to be the problem referred to above. I have (for my distro) the most up-to-date versions of libncurses and libncurses-dev.Sun, 21 Apr 2013 00:49:24 +0200https://ask.sagemath.org/question/10043/sage-in-console-newline-characters/?comment=17838#post-id-17838Comment by kcrisman for <p>I like to use sage in a linux console, rather than the notebook interface, simply for speed and convenience. However, I have problems if I want to edit a multi-line statement. For example, suppose I enter:</p>
<pre><code>for i in range(10):
if is_prime(i):
print i
</code></pre>
<p>If I want to edit this, or maybe just run it again, when I call it up with the history mechanism, what I see is</p>
<pre><code>for i in range(10):^J if is prime(i):^J print i
</code></pre>
<p>This can be very inconvenient if there are lots of short lines. (I can get round this by running sage within GNU screen.) I'm not quite sure how I encourage newlines to be interpreted as, well new lines rather than newline characters, and whether this is a sage, ipython, or console issue.</p>
https://ask.sagemath.org/question/10043/sage-in-console-newline-characters/?comment=17843#post-id-17843You may want to try `%edit`, an ipython magic function which allows this kind of editing.Sat, 20 Apr 2013 08:21:42 +0200https://ask.sagemath.org/question/10043/sage-in-console-newline-characters/?comment=17843#post-id-17843Comment by John Palmieri for <p>I like to use sage in a linux console, rather than the notebook interface, simply for speed and convenience. However, I have problems if I want to edit a multi-line statement. For example, suppose I enter:</p>
<pre><code>for i in range(10):
if is_prime(i):
print i
</code></pre>
<p>If I want to edit this, or maybe just run it again, when I call it up with the history mechanism, what I see is</p>
<pre><code>for i in range(10):^J if is prime(i):^J print i
</code></pre>
<p>This can be very inconvenient if there are lots of short lines. (I can get round this by running sage within GNU screen.) I'm not quite sure how I encourage newlines to be interpreted as, well new lines rather than newline characters, and whether this is a sage, ipython, or console issue.</p>
https://ask.sagemath.org/question/10043/sage-in-console-newline-characters/?comment=17840#post-id-17840What platform is this? I wonder if this is the bug reported at http://trac.sagemath.org/sage_trac/ticket/14405.Sat, 20 Apr 2013 11:59:47 +0200https://ask.sagemath.org/question/10043/sage-in-console-newline-characters/?comment=17840#post-id-17840Comment by tmonteil for <p>I like to use sage in a linux console, rather than the notebook interface, simply for speed and convenience. However, I have problems if I want to edit a multi-line statement. For example, suppose I enter:</p>
<pre><code>for i in range(10):
if is_prime(i):
print i
</code></pre>
<p>If I want to edit this, or maybe just run it again, when I call it up with the history mechanism, what I see is</p>
<pre><code>for i in range(10):^J if is prime(i):^J print i
</code></pre>
<p>This can be very inconvenient if there are lots of short lines. (I can get round this by running sage within GNU screen.) I'm not quite sure how I encourage newlines to be interpreted as, well new lines rather than newline characters, and whether this is a sage, ipython, or console issue.</p>
https://ask.sagemath.org/question/10043/sage-in-console-newline-characters/?comment=17842#post-id-17842What is weird is that ipython 0.13.1 (not the one shipped sage, but same version) has the right behaviour.Sat, 20 Apr 2013 08:23:10 +0200https://ask.sagemath.org/question/10043/sage-in-console-newline-characters/?comment=17842#post-id-17842