Date Tags python

NOTE: This is an update to a previous post.

The following can be used to programmatically set stdin for testing under Python 3.x:

import sys
from io import StringIO
sys.stdin = StringIO()
setinput = lambda x: [
        sys.stdin.seek(0),
        sys.stdin.truncate(0),
        sys.stdin.write(x),
        sys.stdin.seek(0)]

Here is a quick example of using setinput() in Python 3.x:

setinput("Jeff")
name = input("Enter name:")
print(name)

Hi, I am Jeff Rimko!
A computer engineer and software developer in the greater Pittsburgh, Pennsylvania area.