#๐Ÿ”’ od here hello

48 messages ยท Page 1 of 1 (latest)

prisma storm
#

hello

sinful pathBOT
#

@prisma storm

Python help channel opened

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.

prisma storm
#

hello

carmine raptor
#

Hey

prisma storm
#

ill give a screenshot

carmine raptor
#

This is the solution I came up with

young pulsar
carmine raptor
#
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")```
ripe ibex
# young pulsar

sys.stdout.flush() before sleeping would show you the original stuff too I think

prisma storm
#

yeah. i want just the new stuff

normal python
young pulsar
prisma storm
#

so that worked okay

#

sys.dout.flush() mind telling me about that?

#

i know what sys means

young pulsar
#

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.
>>>
prisma storm
#

i knwo what flush means

#

too

normal python
#

print basically writes to sys.stdout

ripe ibex
#

stdout = standard output

prisma storm
#

stdout is still confusing me after the explanation

#

sorry to waste your time'

normal python
#

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

prisma storm
#

so is stdout the output before flush steps in to stop buffering

normal python
#

yep pretty much

prisma storm
#

so stdout is default and you have to tell the computer (unless your os automatically uses flush) to use flush

normal python
#

exactly

prisma storm
#

thank you so much afx

ripe ibex
#

it's not like flush OR stdout are like alternative approaches

prisma storm
#

okay thank you for the specification

#

okay thank you Raju

normal python
#

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'
prisma storm
#

so flush is like a mode of stdout

ripe ibex
#

no, flush is an operation on stdout.

prisma storm
#

yes

ripe ibex
#

like an action, not a state.

prisma storm
#

okay thank you

normal python
#

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

prisma storm
#

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

normal python
#

have fun building your app!

prisma storm
#

more of a terminal program

#

i am 3 days of old as a python programmer and programmer in general

#

but thanks

sinful pathBOT
#
Python help channel closed for inactivity

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.