Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96300

Re: Context-aware return

Path csiph.com!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'context': 0.05; 'e.g.,': 0.07; 'alter': 0.09; 'called.': 0.09; 'interpreter,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'stdout': 0.09; 'sys.stdout': 0.09; 'troubleshoot': 0.09; 'output': 0.13; 'justified': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'tty': 0.16; 'wrote:': 0.16; 'windows': 0.20; 'disable': 0.22; 'strip': 0.22; 'sort': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; '(e.g.,': 0.27; 'function': 0.28; 'ansi': 0.29; 'case).': 0.29; 'allows': 0.30; 'code': 0.30; 'waste': 0.30; "d'aprano": 0.33; 'steven': 0.33; 'message-id:@gmail.com': 0.34; 'me?': 0.34; 'gets': 0.35; 'skip:* 20': 0.35; 'unicode': 0.35; 'something': 0.35; 'sometimes': 0.35; 'but': 0.36; 'there': 0.36; 'cases': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'received:org': 0.37; 'things': 0.38; 'end': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'questions': 0.40; 'your': 0.60; 'behavior': 0.61; 'skip:n 10': 0.62; 'wish': 0.71; 'sounds': 0.76; 'received:89': 0.80; 'colored': 0.91; 'edwards': 0.91; 'thing,': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Akira Li <4kir4.1i@gmail.com>
Subject Re: Context-aware return
Date Thu, 10 Sep 2015 23:15:31 +0300
References <55f1c3c6$0$1659$c3e8da3$5496439d@news.astraweb.com> <msslas$pf8$1@reader1.panix.com>
Mime-Version 1.0
Content-Type text/plain
X-Gmane-NNTP-Posting-Host 89.169.229.68
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)
Cancel-Lock sha1:mcq5OOJZctReW8qQAHsvx93eVpQ=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.339.1441916238.8327.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1441916238 news.xs4all.nl 23852 [2001:888:2000:d::a6]:45449
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:96300

Show key headers only | View raw


Grant Edwards <invalid@invalid.invalid> writes:

> On 2015-09-10, Steven D'Aprano <steve@pearwood.info> wrote:
>
>> I have a function which is intended for use at the interactive interpreter,
>> but may sometimes be used non-interactively. I wish to change it's output
>> depending on the context of how it is being called.
>
> [...]
>
> Sounds like an excellent way to waste somebody's afternoon when they
> start to troubleshoot code that's using your function.  Over and over
> and over we tell newbies who have questions about what something
> returns or how it works
>
>     "Start up an interactive session, and try it!".
>
> If word gets out about functions like yours, we sort of end up looking
> like twits.  
>
>> If I did this thing, would people follow me down the street booing
>> and jeering and throwing things at me?
>
> Only the people who use your function. :)

There are cases when it might be justified to alter the behavior e.g.,
*colorama* allows to strip ANSI codes (e.g., disable colored output) if
stdout is not a tty or *win-unicode-console* make sys.stdout to use
WriteConsoleW() to write Unicode to Windows console (interactive case).

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Context-aware return Steven D'Aprano <steve@pearwood.info> - 2015-09-11 03:54 +1000
  Re: Context-aware return "Sven R. Kunze" <srkunze@mail.de> - 2015-09-10 20:03 +0200
  Re: Context-aware return Ben Finney <ben+python@benfinney.id.au> - 2015-09-11 04:12 +1000
  Re: Context-aware return Ben Finney <ben+python@benfinney.id.au> - 2015-09-11 04:14 +1000
  Re: Context-aware return "Sven R. Kunze" <srkunze@mail.de> - 2015-09-10 20:21 +0200
  Re: Context-aware return "Sven R. Kunze" <srkunze@mail.de> - 2015-09-10 20:24 +0200
  Re: Context-aware return "Sven R. Kunze" <srkunze@mail.de> - 2015-09-10 20:34 +0200
  Re: Context-aware return Chris Angelico <rosuav@gmail.com> - 2015-09-11 04:39 +1000
  Re: Context-aware return Laura Creighton <lac@openend.se> - 2015-09-10 20:40 +0200
  Re: Context-aware return "Sven R. Kunze" <srkunze@mail.de> - 2015-09-10 20:45 +0200
  Re: Context-aware return "Sven R. Kunze" <srkunze@mail.de> - 2015-09-10 20:56 +0200
  Re: Context-aware return Paul Rubin <no.email@nospam.invalid> - 2015-09-10 12:19 -0700
  Re: Context-aware return Grant Edwards <invalid@invalid.invalid> - 2015-09-10 19:23 +0000
    Re: Context-aware return Akira Li <4kir4.1i@gmail.com> - 2015-09-10 23:15 +0300
      Re: Context-aware return Grant Edwards <invalid@invalid.invalid> - 2015-09-10 20:27 +0000
    Re: Context-aware return random832@fastmail.us - 2015-09-10 16:42 -0400
    Re: Context-aware return Rustom Mody <rustompmody@gmail.com> - 2015-09-11 08:55 -0700
    Re: Context-aware return Rustom Mody <rustompmody@gmail.com> - 2015-09-11 08:55 -0700
  Re: Context-aware return Denis McMahon <denismfmcmahon@gmail.com> - 2015-09-11 00:41 +0000
    Re: Context-aware return Ned Batchelder <ned@nedbatchelder.com> - 2015-09-12 16:27 -0700
      Re: Context-aware return Steven D'Aprano <steve@pearwood.info> - 2015-09-17 12:31 +1000
  Re: Context-aware return Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-12 03:11 +0100

csiph-web