Return a function that acts like raw_input but feeds the input list.
(lines)
| 56 | |
| 57 | |
| 58 | def pseudo_input(lines): |
| 59 | """Return a function that acts like raw_input but feeds the input list.""" |
| 60 | ilines = iter(lines) |
| 61 | def raw_in(prompt): |
| 62 | try: |
| 63 | return next(ilines) |
| 64 | except StopIteration: |
| 65 | return '' |
| 66 | return raw_in |
| 67 | |
| 68 | #----------------------------------------------------------------------------- |
| 69 | # Tests |