console programming without scrolling

I am not really sure how to describe it, but here it goes... I started with python a couple of months ago. It is going pretty good. Several of my bash scripts have been converted over to python. I use python every other day at work. Sometimes, I want to challenge myself with new projects.

Back in high school, we had a computer club. The teacher wrote a fish-shark simulation (Wa-Tor). For some reason, I remembered it and I started to write it program. Here is my problem, the program gets my terminal window's rows and columns. My entire fish world is size of the terminal window. Every other move, I want the fish world to be re-drawn. My only problem is that 'print my_ocean' ends up just scrolling.

Example: Chronos 1: print Chronos 2: print

I just want to update the same screen over and over.

Is it possible to stay on your current screen and update it, instead of scrolling? The scrolling does not always look that pretty.

Does that make sense?

6 comments · 100% upvoted · other discussions

comments

42thehammer42

If it's just one or two lines that need updating, you can simply do the following: http://stackoverflow.com/questions/4897359/output-to-the-same-line-overwriting-previous-output-python-2-5

infinull

the '\r' trick won't work because OP is doing a full screen rewrite (If I understand correctly)