On Mon, Mar 2, 2009 at 4:14 AM, Hamish <[email protected]> wrote:
>
> On Feb 25, 1:52 pm, Marco Streng <[email protected]> wrote:
>> I'm doing a long computation in Sage and I'd like to be able to print
>> some status information to the screen, such as the number of database
>> entries that I have tested, or the total time spent on different parts
>> of an algorithm.
>>
>> If I use the print command, then such information will accumulate and
>> make it impossible to scroll back to the rest of my terminal session,
>> or if I use a notebook, it makes the notebook very untidy and long.
>>
>> Is there an easy way to either remove something that I have 'print'-ed
>> before, or (in a notebook) to create some sort of text box in which I
>> can let my code add and remove text?
>
> I don't know about the notebook, but in a terminal you can use the
> '\r' (carriage return) character to jump to the beginning of the line:
>
> sage: print 'abcd\refg'
> efgd
>
> Not that this just overwrites what was there before, so extra
> characters can be leftover if you don't fill the line with spaces
> (e.g. the 'd' above).  This probably isn't a problem though, as I
> suspect you intend something like this:
>
> sage: for i in range(0, 100, 10):
> ....:     print '%s%% complete.\r' % i,
> ....:     sys.stdout.flush()
> ....:     sleep(0.5)
>
> Note the , (comma) at the end of the print line, which suppresses
> printing the newline (and turns off flushing, unfortunately).
>
> Hope this helps,
> Hamish.

The above doesn't work in the notebook.  However, this or more like this
would I think be easy to add to implement for a notebook developer.
The idea would be to add some postprocessing in the cell.py file to output
coming from the compute process... eg., something that "deletes to the beginning
of the line".  This would certainly be easy to implement.

 -- William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to