Skip to content

Commit 3607a39

Browse files
committed
simplify output
1 parent f76f437 commit 3607a39

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

examples/argparse_example.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ def __init__(self, ip_addr=None, port=None, transcript_files=None):
4141
# self.default_to_shell = True
4242

4343

44-
argparser = argparse.ArgumentParser(prog='speak')
44+
argparser = argparse.ArgumentParser()
4545
argparser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
4646
argparser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE')
4747
argparser.add_argument('-r', '--repeat', type=int, help='output [n] times')
4848
argparser.add_argument('words', nargs='+', help='words to say')
4949
@with_argument_parser(argparser)
50-
def do_speak(self, argv, args=None):
50+
def do_speak(self, cmdline, args=None):
5151
"""Repeats what you tell me to."""
5252
words = []
5353
for word in args.words:
@@ -58,10 +58,7 @@ def do_speak(self, argv, args=None):
5858
words.append(word)
5959
repetitions = args.repeat or 1
6060
for i in range(min(repetitions, self.maxrepeats)):
61-
self.stdout.write(' '.join(words))
62-
self.stdout.write('\n')
63-
# self.stdout.write is better than "print", because Cmd can be
64-
# initialized with a non-standard output destination
61+
self.poutput(' '.join(words))
6562

6663
do_say = do_speak # now "say" is a synonym for "speak"
6764
do_orate = do_speak # another synonym, but this one takes multi-line input

0 commit comments

Comments
 (0)