Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: What should Python apps do when asked to show help? Date: Fri, 29 Apr 2016 03:06:22 +1000 Lines: 23 Message-ID: References: <57223b76$0$22140$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de k+jEBmHagjWRGKIgfnJ19gU2WFX80iPUz4ZYz/sd9jZg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'received:209.85.223': 0.03; 'subject:Python': 0.05; 'subject:help': 0.07; 'cc:addr :python-list': 0.09; 'stderr': 0.09; 'stdout': 0.09; 'python': 0.10; 'output': 0.13; '--help': 0.16; '2016': 0.16; 'enough.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:show': 0.16; 'subject:when': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; '(or': 0.23; 'help.': 0.23; 'written': 0.24; 'header:In-Reply-To:1': 0.24; 'command': 0.26; 'fri,': 0.27; 'least': 0.27; 'message- id:@mail.gmail.com': 0.27; '3-5': 0.29; 'accepts': 0.29; 'allows': 0.30; "i'm": 0.30; 'print': 0.30; 'run': 0.33; 'usually': 0.33; "d'aprano": 0.33; 'steven': 0.33; 'stream': 0.33; 'received:google.com': 0.35; 'could': 0.35; 'text': 0.35; 'something': 0.35; 'but': 0.36; 'received:209.85': 0.36; '(3)': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; '(2)': 0.37; 'received:209': 0.38; '(1)': 0.38; 'sure': 0.39; 'whatever': 0.39; 'application': 0.39; 'show': 0.62; 'more': 0.63; "they're": 0.66; 'programs,': 0.72; 'can:': 0.84; 'chrisa': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=utqCEDNaBcsMDCc7BP/yYxwWwNSKMcB9U4woHy/+7xo=; b=eRWLb6G30tL3QH9rZhrv3J/DTcn7rY97v+fflTGvQqaFpbGV7Uwyr0z1c0oX3SAmJ1 Bfa26MkSOcc5MvVxIBvgMjpXcTpCS7AiGwSuBC9Y6HME/WQa3N1xpZc4ee+dDzwT5Uzn UeKSPkGX+KLYCWNVDZhrAWEMBZVSZ7ZYON0/ndWWKNx8DYQJJEbKlS7Y1icejWFrSLoj IPdV+SmuVurLQRAiSlQ1sosY+96s/QEggVYsxaX3J+5q4nxQ7BG4BcreCj6LyFfqjCQs neeJLUnMvRhmWl7JEzmRjpIOjbKsa2/L/qec45Jb3phvDtFhHIW2z3VebpvH8cfNBnNZ 1RGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=utqCEDNaBcsMDCc7BP/yYxwWwNSKMcB9U4woHy/+7xo=; b=C1NbhbFvkgsip83pxEM+mVvCy5xLs8LCy/btcbpcrMln085Xhb29/U3fYyXSvU5kYM sm3sYbuYtjdPaJyZ+/gxCkctSNVI4+kHaEuuQI0BiL1KgY2CiTwgqCdYoqE/xV1UfKOx lxm4qS0oXE9+MH7ef0SM0CO3BwHaarg8UxjNXgPjILyJRBInYhWGnjAiJ/p2Xegx/12e Y3NYvOxckMcmhgkA/Pbv+G8SkNTuoPUIJaN37L5qkVWSawCma6Dl50nw9yY42Zdrt3+m CSSpE1Wh2y+Wnhr3pibkPXth+MPu5l528Siwi8Y6JMeZcUUhYHiZu19C/RduP1lMWvKH s6pQ== X-Gm-Message-State: AOPr4FVI5zwIhVzZUpD6LhsMh3+wFrV+JbGNOU1lJHF0LljFx1nOyJD2S7khFfOMRm61rYb3BVEpxlxqeJWL0g== X-Received: by 10.107.169.13 with SMTP id s13mr17877490ioe.19.1461863183056; Thu, 28 Apr 2016 10:06:23 -0700 (PDT) In-Reply-To: <57223b76$0$22140$c3e8da3$5496439d@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <57223b76$0$22140$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:107809 On Fri, Apr 29, 2016 at 2:33 AM, Steven D'Aprano wrote: > I have an application written in Python which accepts -h or --help to show > help. I can: > > (1) print the help text to stdout; > > (2) run the help text through a pager; > > (3) do something else? > > > Many command line tools simply output help to stdout (or stderr, if they're > evil), I'm not sure stderr is particularly more evil than stdout, but whatever :) What you could do is run the help text through a pager only if stdout is a TTY. That allows it to be grepped conveniently, but also browsed easily. But I wouldn't worry about that unless you have at least 3-5 pages of screed - for most programs, just dumping the text to a standard stream is usually enough. ChrisA