blob: dfb3da0b2f8ba67532cb30dccbbe903133c7a0e8 [file] [log] [blame]
Guido van Rossumf06ee5f1996-11-27 19:52:01 +00001#! /usr/bin/env python
Guido van Rossumec758ea1991-06-04 20:36:54 +00002
3# suff
4#
5# show different suffixes amongst arguments
6
7import sys
8
9def main():
Tim Peters70c43782001-01-17 08:48:39 +000010 files = sys.argv[1:]
11 suffixes = {}
Andrew M. Kuchlingac6df952003-05-13 18:14:25 +000012 for filename in files:
13 suff = getsuffix(filename)
Tim Peters70c43782001-01-17 08:48:39 +000014 if not suffixes.has_key(suff):
15 suffixes[suff] = []
Andrew M. Kuchlingac6df952003-05-13 18:14:25 +000016 suffixes[suff].append(filename)
Tim Peters70c43782001-01-17 08:48:39 +000017 keys = suffixes.keys()
18 keys.sort()
19 for suff in keys:
Walter Dörwald70a6b492004-02-12 17:35:32 +000020 print repr(suff), len(suffixes[suff])
Guido van Rossumec758ea1991-06-04 20:36:54 +000021
Andrew M. Kuchlingac6df952003-05-13 18:14:25 +000022def getsuffix(filename):
Tim Peters70c43782001-01-17 08:48:39 +000023 suff = ''
Andrew M. Kuchlingac6df952003-05-13 18:14:25 +000024 for i in range(len(filename)):
25 if filename[i] == '.':
26 suff = filename[i:]
Tim Peters70c43782001-01-17 08:48:39 +000027 return suff
Guido van Rossumec758ea1991-06-04 20:36:54 +000028
29main()