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