Hi :-)
do you know how to move up one line in the terminal?
Explanation with an example:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from time import sleep
def test():
print "begin"
i = 1
s = "#"
while i < 5:
print s
sleep(1)
i += 1
s = s + "#"
print "end"
def main():
test()
if __name__ == '__main__': main()
That code will output this:
$ ./test.py
begin
#
##
###
####
end
But i'd like to modify it so that it outputs this:
$ ./test.py
begin
#
$ ./test.py
begin
##
$ ./test.py
begin
###
$ ./test.py
begin
#####
end
So that there is an "animation like" effect...
Using a comma with the print is not the solution because the program only outputs the string once the program goes out of the while. In my exemple it outputs this if i use a comma with the print
First
$ ./test.py
begin
And then:
$ ./test.py
begin
# ## ### #### end
I hope my explanation is clear and understandable...
Thank you very much for your help! :-)