1 | n/a | #! /usr/bin/env python3 |
---|
2 | n/a | |
---|
3 | n/a | # suff |
---|
4 | n/a | # |
---|
5 | n/a | # show different suffixes amongst arguments |
---|
6 | n/a | |
---|
7 | n/a | import sys |
---|
8 | n/a | |
---|
9 | n/a | |
---|
10 | n/a | def main(): |
---|
11 | n/a | files = sys.argv[1:] |
---|
12 | n/a | suffixes = {} |
---|
13 | n/a | for filename in files: |
---|
14 | n/a | suff = getsuffix(filename) |
---|
15 | n/a | suffixes.setdefault(suff, []).append(filename) |
---|
16 | n/a | for suff, filenames in sorted(suffixes.items()): |
---|
17 | n/a | print(repr(suff), len(filenames)) |
---|
18 | n/a | |
---|
19 | n/a | |
---|
20 | n/a | def getsuffix(filename): |
---|
21 | n/a | name, sep, suff = filename.rpartition('.') |
---|
22 | n/a | return sep + suff if sep else '' |
---|
23 | n/a | |
---|
24 | n/a | |
---|
25 | n/a | if __name__ == '__main__': |
---|
26 | n/a | main() |
---|