print() does not print until copytree() has finished

Robert Strauch

In a Python script I copy a directory tree and would like to print some text like this...

print("Copying... ", end="")
shutil.copytree(src, dest)
print("DONE")

However the text Copying... is not printed until the script has finished.

Jashandeep Sohi

You need to flush STDOUT, but no need to bring sys.stdout into the picture. print can do that for you:

print("Copying... ", end="", flush=True)
shutil.copytree(src, dest)
print("DONE")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why the main does not wait until the async method has finished?

From Dev

Why does my parallel command print “Starting” and ”Finished“ at the same time?

From Dev

Wait until gobalEval has finished

From Dev

Wait until gobalEval has finished

From Dev

My printer has jobs waiting but does not print

From Dev

Print out only finished memberList

From Dev

Delay window.print() until page has loaded within an ajax request to avoid a blank print screen?

From Dev

How to wait until networking by Alamofire has finished?

From Dev

rxjs throttle fetch until request has finished

From Dev

Android - How to wait until a SnapshotListener has finished?

From Dev

Print only prints after functions are finished executing

From Dev

While loops finished but print all its variables

From Dev

Print range - print from page x until end of document

From Dev

How to stop viewWillAppear from completing until a function has finished

From Dev

Is it possible to not repeat a timedtask until the old one has finished?

From Dev

Dont run a cron php task until last one has finished

From Dev

Swift wait until dataTaskWithRequest has finished to call the return

From Dev

Can a for-loop wait until a function within it has finished executing?

From Dev

Download files from UIDocumentPicker and wait until download has finished

From Dev

Delaying jQuery toggleClass effect until a slide animation has finished

From Dev

Don't run function until .hide() has finished its animation

From Dev

Android asynctask show progress dialog until function has finished

From Dev

Running audio thread prevents touchscreen input until it has finished

From Dev

Dont run a cron php task until last one has finished

From Dev

Delay emission of observable until the execution of the current Angular tick has finished

From Dev

Launch an application and wait until it has finished without blocking redraw

From Dev

How to make a python Script wait until download has finished

From Dev

Prevent any click event on the computer until macro has finished

From Dev

How to wait until canvas has finished re-rendering?

Related Related

  1. 1

    Why the main does not wait until the async method has finished?

  2. 2

    Why does my parallel command print “Starting” and ”Finished“ at the same time?

  3. 3

    Wait until gobalEval has finished

  4. 4

    Wait until gobalEval has finished

  5. 5

    My printer has jobs waiting but does not print

  6. 6

    Print out only finished memberList

  7. 7

    Delay window.print() until page has loaded within an ajax request to avoid a blank print screen?

  8. 8

    How to wait until networking by Alamofire has finished?

  9. 9

    rxjs throttle fetch until request has finished

  10. 10

    Android - How to wait until a SnapshotListener has finished?

  11. 11

    Print only prints after functions are finished executing

  12. 12

    While loops finished but print all its variables

  13. 13

    Print range - print from page x until end of document

  14. 14

    How to stop viewWillAppear from completing until a function has finished

  15. 15

    Is it possible to not repeat a timedtask until the old one has finished?

  16. 16

    Dont run a cron php task until last one has finished

  17. 17

    Swift wait until dataTaskWithRequest has finished to call the return

  18. 18

    Can a for-loop wait until a function within it has finished executing?

  19. 19

    Download files from UIDocumentPicker and wait until download has finished

  20. 20

    Delaying jQuery toggleClass effect until a slide animation has finished

  21. 21

    Don't run function until .hide() has finished its animation

  22. 22

    Android asynctask show progress dialog until function has finished

  23. 23

    Running audio thread prevents touchscreen input until it has finished

  24. 24

    Dont run a cron php task until last one has finished

  25. 25

    Delay emission of observable until the execution of the current Angular tick has finished

  26. 26

    Launch an application and wait until it has finished without blocking redraw

  27. 27

    How to make a python Script wait until download has finished

  28. 28

    Prevent any click event on the computer until macro has finished

  29. 29

    How to wait until canvas has finished re-rendering?

HotTag

Archive