Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 5c1b22b093f6adf6113b0063a543988e2e28c005 authored by cvs2svn on 10 January 2002, 16:25:57 UTC
This commit was manufactured by cvs2svn to create tag 'r212c1'.
Tip revision: 5c1b22b
suff.py
#! /usr/bin/env python

# suff
#
# show different suffixes amongst arguments

import sys

def main():
    files = sys.argv[1:]
    suffixes = {}
    for file in files:
        suff = getsuffix(file)
        if not suffixes.has_key(suff):
            suffixes[suff] = []
        suffixes[suff].append(file)
    keys = suffixes.keys()
    keys.sort()
    for suff in keys:
        print `suff`, len(suffixes[suff])

def getsuffix(file):
    suff = ''
    for i in range(len(file)):
        if file[i] == '.':
            suff = file[i:]
    return suff

main()
back to top