#Print statements are not working until after loop?

1 messages · Page 1 of 1 (latest)

twilit trellisBOT
#

@meager shore

File Attachments Not Allowed

For safety reasons we do not allow file and video attachments.

Feather Said

I am making a basic library that prints text slowly to the screen, almost like dialog in an RPG, the only problem, is that the text does not slowly appear on the screen, the console remains empty until it suddenly appear! I have the code for everything below and a video demonstrating it.

Code for the library:

import time

step = 0
split = 0

def slowscantext(text,delay=0.05, newline=True):
    split = list(text)
    for x in split:
        print(x, end="")
        time.sleep(delay)
    if newline == True:
        print("\n" end="")
Code Formatting

You can share your code using triple backticks like this:
```
YOUR CODE
```

Large Portions of Code

For longer scripts use Hastebin or GitHub Gists and share the link here

Ignored these files
  • simplescreenrecorder-2023-01-15_18.54.09.mp4
meager shore
#

This is the video

scenic rampart
#

Print buffers and outputs once the buffer is full, a new line is printed, or the application exits.

You need to either flush the buffer or run unbuffered.

To run unbuffered pass the -u flag to python.

python -u test.py

To flush do

print(x, end="", flush=True)
meager shore
#

eeee

#

why is it like this

scenic rampart
#

Because writing to stdout in the terminal is slow. So buffering makes things faster.

meager shore
#

okay

#

well I got it to function

#

time to make a text adventure using thias