Why is the output of print() functions in Python scripts not captured by > redirection or piping? Itsn't it just going to stdout? I feel like I'm misunderstanding something very basic here, but oh well.

OK the thing I'm encountering is more subtle than I described, but... my script which produces command line output with print functions doesn't put anything into a text file when it's redirected (nor does it apparently provide anything to a pipe)

Show thread

Yeah, hm, testing this out with a simpler script is reassuring about my basic understanding of stdout and redirecting, because... it works. but now debugging this is going to be weird

· · Web · 1 · 0 · 1

figured it out!! I was using os.get_terminal_size() to format the output, but when you redirect it that results in an OSError for "Inappropriate ioctl" (but I was swallowing that error for sloppy reasons)

Show thread
Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!