Python3 sleep() problem

Not enough credits to upvote
0
Not enough credits to downvote
By: Speedbird (SysAdmin), Created 8 years ago, Updated 8 years ago.
I was writing a simple program on Python 3.1 and I stumbled upon this:

If I run this on the IDLE it works as intended - prints "Initializing." and then adds two dots, one after each second, and waits for input.

from time import sleep

def initialize():
print('Initializing.', end='')
sleep(1)
print(" .", end='')
sleep(1)
print(" .", end='')
input()

initialize()


The problem is that when I double-click the .py to execute the file, it runs on python.exe instead of pythonw.exe, and strange things happen: it joins all the sleep() times i.e. makes me wait for 2 seconds, and then prints the whole string Initializing. . . at once. Why does this happen? Is there a way to avoid that happening in the terminal? It works fine if I use the IDLE in both windows and linux.
Tags

1 Responses

Not enough credits to upvote
0
Not enough credits to downvote
By: maniche1 (Member), 8 years ago
import sys
sys.stdout.flush()


try this

You may post an answer by signing in or registering for an account Here

QA-Stack.com

Welcome to QA-Stack.com - QA-Stack is a Q&A open source web application written in the best programming language in the galaxy: Python and using the best web framework in the solar system: web2py, be sure to check forum.qa-stack.com for discussions about this site. Have a great stay.

QA-Stack source code is available thanks to the cool folks at bitbucket.org, browse the source, or follow updates to this projects by visiting the qa-stack page at https://bitbucket.org/speedbird/qastack.

Documentation

Documentation for QA-Stack can be found at the QA-Stack Google Docs Page.

Bugs

Submit your bugs in i-track, another web application made by the same author (we eat our own dog food): View currently submitted bugs on i-track.

Popular Tags