You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fixed a bug where I did next(stdin()) instead of saving the iterator
Made StopIteration more user friendly
got rid of useless line
Added test case for generator
changed naming of mock stdin to match python naming convention
areplInputIterator=Nonedefinput(prompt=None):
globalareplInputIteratorifpromptisnotNone: print(prompt)
try:
ifareplInputIteratorisnotNone:
try:
returnnext(areplInputIterator)
exceptStopIteration:
# give simple user-friendly error, we dont want users worry about error in arepl source coderaiseStopIteration("There is no more input") fromNoneelse:
iftype(standard_input) isstr:
areplInputIterator=iter([lineforlineinstandard_input.split()])
elifcallable(standard_input):
areplInputIterator=standard_input()
else:
areplInputIterator=iter([lineforlineinstandard_input])
returnnext(areplInputIterator)
exceptNameError:
print("AREPL requires standard_input to be hardcoded, like so: standard_input = 'hello world'; print(input())")
# user can define standard input with three ways:defstandard_input():
yield'hello'yield'world'standard_input= ["hello", "world"]
standard_input="hello\nworld"x=input() # should be helloy=input() # should be worldz=input() # should result in StopIteration error saying no more input
The text was updated successfully, but these errors were encountered: