Index: Demo/comparisons/sortingtest.py =================================================================== --- Demo/comparisons/sortingtest.py (revisão 86657) +++ Demo/comparisons/sortingtest.py (cópia de trabalho) @@ -23,6 +23,26 @@ # - Outputs the sorted fields with exactly one space between them # - Handles blank input lines correctly +USAGE = ''' + Usage: + + $ echo var1=23 other=14 ditto=23 fred=2 | python3 sortingtest.py + fred=2 other=14 ditto=23 var1=23 + + Or you can use a file with the same standard: + + $ python3 sortingtest.py < names.txt + fred=2 other=14 ditto=23 var1=23 + + There is an alternative to enter the pattern in the command line: + Type in the end of the line. + To stop you can use the EOF, Ctrl+D on Linux. + + $ python3 sortingtest.py + var1=23 other=14 ditto=23 fred=2 + fred=2 other=14 ditto=23 var1=23 +''' + import re import sys @@ -42,4 +62,8 @@ print("%s=%s" % (var, num), end=' ') print() -main() +def usage(): + print(USAGE) + +if __name__ == '__main__': + main()