I'm working on a little IRC bot called ChocoBot, and my aim in its creation is to make it fun to use. So I'm trying to make it user-friendly by trying to emulate more human-like "speech"--for example, adding in pause for dramatic suspense. That being said, I'll elaborate on what it is specifically I'm trying to do:
In this case, I'm trying to add in "awkward pause" (you know, like when you say "Uh..." after finding out that your girlfriend is actually your cousin, and then briefly exclaiming "I need to take a shower."). The way I want it to appear is by first printing the initial statement (in this case, "Uh"), then following that directly with a "." after a slight delay, and finally ending the sentence in an abrupt and awkward way ("I need to take a shower."). I've tried a couple of different things; this is what I have so far:
from time import sleep t1 = "Uh" t2 = ". . ." t2s = t2.split() print(t1) for d in t2s: sleep(1) print(d) print(" I need to take a shower.")
What this gives me is something like this:
I need to take a shower.
I've tried replacing print() with sys.stdout.write(), but while the output stays on one line, the delay is saved until the for loop finishes. Which is kind of annoying.
If there's a better way to do this, please let me know. Thanks!