Blinky Program

R

Ryan Spencer

Hello again Everyone,

I spent a small amount of time recently writing a program that "blinks"
text. I did it by first having a user input a string,
sys.stdout.write-ing the string, then backing up judging by the number of
characters the string has, re-stdout's over it with blank spaces (judged
again by it's character count), and then backs up again in a never ending
while loop. It keeps each blink .5 seconds spaced as well, and all in the
same position.

Here is the code.

[start code]

#blinky.py
#Make a blinking user inputed (strings) character by using self made "blinky"
#function.

strings = raw_input("Please enter something to blink: ")

#blinky(string_argument, time_pause)
def blinky(strings1, pause):

import string,time,sys

string_length = len(strings1)

replacement = string.replace(strings1,strings1," ")

float(pause)

while 1:
sys.stdout.write(strings1)
sys.stdout.flush()
time.sleep(pause)

sys.stdout.write("\b"*string_length)

sys.stdout.write(" "*string_length)
sys.stdout.flush()
time.sleep(pause)

sys.stdout.write("\b"*string_length)

blinky(strings, .5)

[end code]

My question is that I was recently informed by someone that I could help
free up some memory usage by alleviating the sys.stdout.flush's in the
code, but I need those in order to keep the "blinking" text in place.

Is there any way I can actually free up memory usage in the terms of the
sys.stdout.flush that any of you can notice? I'm simply curious now after
being informed.

Thanks again,

~Ryan
 
?

=?ISO-8859-1?Q?Gerhard_H=E4ring?=

Ryan said:
[..] I was recently informed by someone that I could help
free up some memory usage by alleviating the sys.stdout.flush's in the
code, [...]

This decidedly sounds like somebody's brainfart.

-- Gerhard
 
R

Ryan Spencer

Ryan said:
[..] I was recently informed by someone that I could help
free up some memory usage by alleviating the sys.stdout.flush's in the
code, [...]

This decidedly sounds like somebody's brainfart.

-- Gerhard

Hehe, All righty then. Thanks Gerhard.

~Ryan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top