Commit 5bf2952318d28b496aa5f35112a5de7a3f13bbf8
1 parent
f9dae063
improve argument checking
Showing
1 changed file
with
3 additions
and
3 deletions
examples/ts_distributions.py
| @@ -95,13 +95,13 @@ if __name__ == '__main__': | @@ -95,13 +95,13 @@ if __name__ == '__main__': | ||
| 95 | Create TS distribution in a number of energy bands. | 95 | Create TS distribution in a number of energy bands. |
| 96 | """ | 96 | """ |
| 97 | # Get input arguments | 97 | # Get input arguments |
| 98 | - usage = "ts_distributions <max_threads>" | ||
| 99 | - if len(sys.argv) < 1: | 98 | + usage = "ts_distributions [max_threads]" |
| 99 | + if len(sys.argv) < 1 or len(sys.argv) > 2: | ||
| 100 | print usage | 100 | print usage |
| 101 | sys.exit() | 101 | sys.exit() |
| 102 | 102 | ||
| 103 | # Set maximum number of threads (default: 1) | 103 | # Set maximum number of threads (default: 1) |
| 104 | - if len(sys.argv) > 1: | 104 | + if len(sys.argv) == 2: |
| 105 | max_threads = int(sys.argv[1]) | 105 | max_threads = int(sys.argv[1]) |
| 106 | else: | 106 | else: |
| 107 | max_threads = 1 | 107 | max_threads = 1 |