title: Append to previous line
body: <p>I'm doing folder/file processing in Python. To notify the user, I output some messages to the console. These messages look similar to this:</p>
  
  <pre><code>Creating folders...
  DONE
  Creating files...
  DONE
  All done!
  </code></pre>
  
  <p>This is fine if the process is short, but in my case, the process (and the messages) is not short. I don't want to waste new lines on the success/fail messages. I want them to look like this:</p>
  
  <pre><code>Creating folders... DONE
  Creating files... DONE
  All done!
  </code></pre>
  
  <p>The trick is to have "DONE" strings append to previous line after the specific task is completed. So, first I just see:</p>
  
  <pre><code>Creating folders...
  </code></pre>
  
  <p>and when the task is done, it becomes:</p>
  
  <pre><code>Creating folders... DONE
  </code></pre>
  
  <p>and moves on to the next task. I've tried not ending the lines, but it didn't work:</p>
  
  <pre><code>print("Creating folders... ", end="")
  time.sleep(2) # fake process
  print("DONE")
  time.sleep(1)
  print("Creating files... ", end="")
  time.sleep(2)
  print("DONE")
  </code></pre>
  
  <p>Well, it works, but both strings (task... result) show up at the same time (after the task is done). I don't see the transition I've mentioned above.</p>
  
  <p>I've found another way, move to the start of the line and replace the string:</p>
  
  <pre><code>print("Creating folders... ", end="\r")
  time.sleep(2) # fake process
  print("Creating folders... DONE")
  time.sleep(1)
  print("Creating files... ", end="\r")
  time.sleep(2)
  print("Creating files... DONE")
  </code></pre>
  
  <p>This seems to produce the desired effect, but I'm repeating and extending the previous message. I'd rather just output the result, not repeat the task message again.</p>
  
  <p>Is there a simpler solution to this?</p>
  
  <hr>
  
  <p>Also, why doesn't the first method I've tried work? I print a text, and not end the line. After some time I add another text and this gets appended to the previous line, because there's no line-break. Since there's time difference between two prints, I should see the transition, but I don't. They get printed at the same time. Why is that?</p>