Some examples in mypy-primer uses input and that doesn't work currently.
Proposal
Make it possible to specify stdin and run the program with that as stdin.
Suggested format is:
<span id="data-greet" data-stdin='"foo\n45"'></span>
```{.python .example .hijack-input #greet}
def greet(name):
print(f"Hello, {name}!")
if __name__ == '__main__':
name = input("Enter your name: ")
age = input("Enter your age: ")
greet(name)
print(f"You will be {age + 1} years old next year.")
```
Please not that the input is specified as JSON.
PoC
inputs = iter(["foo", "45"])
def new_input(prompt):
print(prompt, end="")
x = next(inputs)
print(x)
return x
input = new_input
def greet(name):
print(f"Hello, {name}!")
if __name__ == '__main__':
name = input("Enter your name: ")
age = input("Enter your age: ")
greet(name)
print(f"You will be {age + 1} years old next year.")
Some examples in mypy-primer uses
input
and that doesn't work currently.Proposal
Make it possible to specify stdin and run the program with that as stdin.
Suggested format is:
Please not that the input is specified as JSON.
PoC