Mercurial > cpython-lru_cache-weakref
view Tools/scripts/suff.py @ 62405:3afc7d8a445a
Issue #8939: Improve arg.rst
* Add :ctype: to Py_BEGIN_ALLOW_THREADS and int
* "s" and "s#" formats of Py_BuildValue(): specify that the Python object type
is str in the description
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Fri, 18 Jun 2010 23:59:45 +0000 |
| parents | fcfe324663a6 |
| children | 5ae390ac6c61 |
line wrap: on
line source
#! /usr/bin/env python3 # suff # # show different suffixes amongst arguments import sys def main(): files = sys.argv[1:] suffixes = {} for filename in files: suff = getsuffix(filename) if suff not in suffixes: suffixes[suff] = [] suffixes[suff].append(filename) keys = sorted(suffixes.keys()) for suff in keys: print(repr(suff), len(suffixes[suff])) def getsuffix(filename): suff = '' for i in range(len(filename)): if filename[i] == '.': suff = filename[i:] return suff if __name__ == '__main__': main()
