Read the input data in the most optimal way
(numbers)
| 35 | |
| 36 | |
| 37 | def read_numbers(numbers): |
| 38 | """ |
| 39 | Read the input data in the most optimal way |
| 40 | """ |
| 41 | if isiterable(numbers): |
| 42 | for number in numbers: |
| 43 | yield float(str(number).strip()) |
| 44 | else: |
| 45 | with open(numbers) as fh: |
| 46 | for number in fh: |
| 47 | yield float(number.strip()) |
| 48 | |
| 49 | |
| 50 | def run_demo(): |