#๐ od here hello
48 messages ยท Page 1 of 1 (latest)
@prisma storm
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
hello
Hey
ill give a screenshot
This is the solution I came up with
import sys
import time
print("originalstuff....", end="\r")
time.sleep(1)
sys.stdout.write("\033[K") # clear from cursor to end of line
print("originalstuff")```
sys.stdout.flush() before sleeping would show you the original stuff too I think
yeah. i want just the new stuff
also adding argument flush=True in first print statement
so that worked okay
sys.dout.flush() mind telling me about that?
i know what sys means
hmm
>>> import sys
>>> help(sys.stdout.flush)
Help on built-in function flush:
flush() method of _io.TextIOWrapper instance
Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
>>>
print basically writes to sys.stdout
stdout = standard output
imagine stdout as just the output. writing to it is writing to the output. so sys.stdout.write("hello") is telling the OS "HEY stick 'hello' in the OUTPUT please!" so the OS puts 'hello' in stdout which the terminal emulator reads from and displays for you to see
so is stdout the output before flush steps in to stop buffering
yep pretty much
so stdout is default and you have to tell the computer (unless your os automatically uses flush) to use flush
exactly
thank you so much afx
stdout is your output stream
flush (or write) is an operation you perform on stdout
it's not like flush OR stdout are like alternative approaches
imagine like this:
program: hey STDOUT 'a'
stdout: received 'a'
program: hey STDOUT 'b'
stdout: received 'b'
program: hey STDOUT '\n'
stdout: received '\n'
stdout: okay looks like that's it. i'll flush it now!
stdout: my current buffer is 'ab\n' <- combination of stuff gotten from program
stdout: hey TERMINAL here's 'ab\n'
terminal: hey OD here's 'ab\n'
so flush is like a mode of stdout
no, flush is an operation on stdout.
yes
like an action, not a state.
okay thank you
like a toilet. you don't want to waste water every time you put something into it. so you put all your stuff into it and flush once -- works pretty much the same
okay. i think i understand it now.
i think my need for help is done for now. i can't explain how appreciative i am of you guys
have fun building your app!
more of a terminal program
i am 3 days of old as a python programmer and programmer in general
but thanks
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.