On Mar 19, 2:21 pm, Terry Reedy <tjre...@udel.edu> wrote: > On 3/19/2010 1:42 PM, Kevin Adams wrote: > > > Please forgive me if im posting this to the wrong group. > > Just the right place. I would suggest a more informative title in the > future though. 'Problem with print and sleep.', for instance. > > > > > I'm new to Python, learning Python3 from the O'rielly "Learning > > Python" book. Reading > > about operator overloading, specifically __getitem__. I put together > > a small bit of code to > > do some experimenting and threw in a timer so i can see it do its > > thing. > > Good idea. Welcome to Python. > > > For some reason > > the time.sleep(x) function doesnt work when my print function includes > > "end=''". > > I cut your code, pasted it into IDLE edit window, and made two minor > modifications. For me (3.1, winxp) it works perfectly either way -- > chars print at 1 sec intervals either vertically or horizonatally. So I > am not sure what you are claiming. > > > > > Thanks in advance for any help. > > > ---code--- > > > class TestClass(): > > def __init__(self): > > self.data = "I was far from home and the spell of the eastern > > sea was upon me." > > I shortened string > > > > > def __getitem__(self,i): > > return self.data[i] > > > import time > > > if __name__ == "__main__": > > > me = TestClass() > > for x in me: > > print(x,end='') #if i remove the 'end=''' it performs as i'd > > expect > > time.sleep(int(2)) > > int(2) == 2, so delete irrelevant call, and 1 sec is enough > > Terry Jan Reedy
Thanks to all!!! It did indeed turn out to be a need to flush the stdout. K ps. sorry for the brief subject, i wasnt finish and hit send before comming back to it. -- http://mail.python.org/mailman/listinfo/python-list