I like to include a function function for printing to stderr so I don't need to keep typing the "file=": def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) Most of the time when you're reading from stdin, you'll want to process one line at a time. If you don't need a context manager for some other reason, you can just treat sys.stdin as an iterable: for line in sys.stdin: if len(line) == 0: # End of file. Do final stuff here sys.exit(0) line = line.rstrip() Notice the rstrip(): reading includes the terminating (CR and) LF, and you usually don't want them as part of the data.
250K Subs - congratulations - this has always been a great channel - always informative and interesting. All the best 🤗
A lot of information, very good to watch after some previous videos about theory if in out and error streams in any OS.
11:00 print has a flush parameter and I can avoid the printing the new line on print function calls.
Useful video :) I learned something today :)
0:00 I'm wondering if I need this, let's see.
I like to include a function function for printing to stderr so I don't need to keep typing the "file=":
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
Most of the time when you're reading from stdin, you'll want to process one line at a time. If you don't need a context manager for some other reason, you can just treat sys.stdin as an iterable:
for line in sys.stdin:
if len(line) == 0:
# End of file. Do final stuff here
sys.exit(0)
line = line.rstrip()
Notice the rstrip(): reading includes the terminating (CR and) LF, and you usually don't want them as part of the data.
Good job ❤
very helpful! thank you
Really useful
I wonder if that works with logging....
Thanks 😊
thanks
echo 'i learned' | python3 -c "print(sys.stdin.read(),end='this')"
Thanks 🤍
POPos is no longer my fav distro. nvim is still running on version 6.1.
You should try a WM in Arch. May be Hyprland or sway
information , ℹ️
Thx_.
Zoom your video blurry