|
1 | | -#!/usr/bin/env python |
| 1 | +#!/usr/bin/env python3 |
2 | 2 | # -*- mode: python; coding: utf-8; indent-tabs-mode: nil -*- |
3 | 3 | # vim: set filetype=python fileencoding=utf-8 expandtab sw=4 sts=4: |
4 | 4 |
|
5 | | -import sys |
6 | 5 | import os |
7 | 6 | from optparse import OptionParser, OptionGroup, SUPPRESS_HELP, SUPPRESS_USAGE |
8 | 7 |
|
9 | | -class MyCallback(object): |
| 8 | +class MyCallback: |
10 | 9 | def __init__(self): |
11 | 10 | self.counter = 0 |
12 | 11 | def __call__(self, option, opt, val, parser): |
13 | 12 | self.counter += 1 |
14 | | - print "--- MyCallback --- " + str(self.counter) + ". time called" |
15 | | - print "--- MyCallback --- option.action(): " + option.action |
16 | | - print "--- MyCallback --- option.type(): " + (option.type if option.type else "") |
17 | | - print "--- MyCallback --- opt: " + opt |
18 | | - print "--- MyCallback --- val: " + (val if val else "") |
19 | | - print "--- MyCallback --- parser.usage(): " + parser.usage |
20 | | - print |
| 13 | + print("--- MyCallback --- " + str(self.counter) + ". time called") |
| 14 | + print("--- MyCallback --- option.action(): " + option.action) |
| 15 | + print("--- MyCallback --- option.type(): " + (option.type if option.type else "")) |
| 16 | + print("--- MyCallback --- opt: " + opt) |
| 17 | + print("--- MyCallback --- val: " + (val if val else "")) |
| 18 | + print("--- MyCallback --- parser.usage(): " + parser.usage) |
| 19 | + print() |
21 | 20 |
|
22 | 21 | def main(): |
23 | 22 | usage = \ |
@@ -112,40 +111,40 @@ def main(): |
112 | 111 |
|
113 | 112 | options, args = parser.parse_args() |
114 | 113 |
|
115 | | - print "clear:", ("false" if options.no_clear else "true") |
116 | | - print "string:", options.string if options.string else "" |
117 | | - print "clause:", options.clause |
118 | | - print "k:", options.k if options.k else "" |
119 | | - print "verbosity:", options.verbosity |
120 | | - print "number:", options.number |
121 | | - print "int:", options.int |
122 | | - print "float: %g" % (options.float,) |
| 114 | + print("clear:", ("false" if options.no_clear else "true")) |
| 115 | + print("string:", options.string if options.string else "") |
| 116 | + print("clause:", options.clause) |
| 117 | + print("k:", options.k if options.k else "") |
| 118 | + print("verbosity:", options.verbosity) |
| 119 | + print("number:", options.number) |
| 120 | + print("int:", options.int) |
| 121 | + print("float: %g" % (options.float,)) |
123 | 122 | c = complex(0) |
124 | 123 | if options.complex is not None: |
125 | 124 | c = options.complex |
126 | | - print "complex: (%g,%g)" % (c.real, c.imag) |
127 | | - print "choices:", options.choices if options.choices else "" |
128 | | - print "choices-list:", options.choices_list if options.choices_list else "" |
129 | | - print "more:", |
130 | | - print ", ".join(options.more if options.more else []) |
| 125 | + print("complex: (%g,%g)" % (c.real, c.imag)) |
| 126 | + print("choices:", options.choices if options.choices else "") |
| 127 | + print("choices-list:", options.choices_list if options.choices_list else "") |
| 128 | + print("more: ", end="") |
| 129 | + print(", ".join(options.more if options.more else [])) |
131 | 130 |
|
132 | | - print "more_milk:" |
| 131 | + print("more_milk:") |
133 | 132 | for opt in (options.more_milk if options.more_milk else []): |
134 | | - print "-", opt |
| 133 | + print("-", opt) |
135 | 134 |
|
136 | | - print "hidden:", options.hidden if options.hidden else "" |
137 | | - print "group:", ("true" if options.g else "false") |
| 135 | + print("hidden:", options.hidden if options.hidden else "") |
| 136 | + print("group:", ("true" if options.g else "false")) |
138 | 137 |
|
139 | | - print "option1:", options.option1 |
140 | | - print "option2:", options.option2 |
| 138 | + print("option1:", options.option1) |
| 139 | + print("option2:", options.option2) |
141 | 140 |
|
142 | | - print "width:", options.width |
143 | | - print "height:", options.height |
| 141 | + print("width:", options.width) |
| 142 | + print("height:", options.height) |
144 | 143 |
|
145 | | - print |
146 | | - print "leftover arguments: " |
| 144 | + print() |
| 145 | + print("leftover arguments: ") |
147 | 146 | for arg in args: |
148 | | - print "arg: " + arg |
| 147 | + print("arg: " + arg) |
149 | 148 |
|
150 | 149 | return 0 |
151 | 150 |
|
|
0 commit comments