[Tutor] getting input for stdin

Danny Yoo dyoo at hashcollision.org
Mon Dec 8 02:44:38 CET 2014

> I need to get the stdin input from the text I type into the same text file
> that I have stdout at. How do I do that. None of the answers at
> stackoverflow got me going. Any help on a code snippet would be appreciated.

In-place edits of a file are dangerous, especially as a beginner.
This is because if your program makes a mistake before the end, you
have very limited ways to recover.

What's usually better practice is to write outputs to a separate file,
with a similar-but-different name.  That way, once your program has
completed, you can inspect the contents of the new file, and then if
things look ok, finally you can copy the new file over the old file.

Can you do this instead?

More information about the Tutor mailing list