#!/usr/bin/env python3 # Copyright (c) 2008-11 Qtrac Ltd. All rights reserved. # This program or module is free software: you can redistribute it and/or # modify it under the terms of the GNU General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. It is provided for educational # purposes and is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. import sys Language = "en" ENGLISH = {0: "zero", 1: "one", 2: "two", 3: "three", 4: "four", 5: "five", 6: "six", 7: "seven", 8: "eight", 9: "nine"} FRENCH = {0: "zero", 1: "un", 2: "deux", 3: "trois", 4: "quatre", 5: "cinq", 6: "six", 7: "sept", 8: "huit", 9: "neuf"} def main(): if len(sys.argv) == 1 or sys.argv[1] in {"-h", "--help"}: print("usage: {0} [en|fr] number".format(sys.argv[0])) sys.exit() args = sys.argv[1:] if args[0] in {"en", "fr"}: global Language Language = args.pop(0) print_digits(args.pop(0)) def print_digits(digits): dictionary = ENGLISH if Language == "en" else FRENCH for digit in digits: print(dictionary[int(digit)], end=" ") print() main()