Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #96276
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed7.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.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'context': 0.05; 'differently': 0.07; '[1,': 0.09; 'behave': 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; 'throw': 0.09; 'python': 0.10; 'output': 0.13; 'interpreter': 0.15; '999': 0.16; 'bind': 0.16; 'goal,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'space;': 0.16; 'exists': 0.18; 'function,': 0.22; "i've": 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'function': 0.28; 'obscure': 0.29; 'prints': 0.29; 'branch': 0.30; 'morning': 0.32; "d'aprano": 0.33; 'steven': 0.33; "i'll": 0.33; 'me?': 0.34; 'except': 0.34; 'so,': 0.35; 'possible,': 0.35; "isn't": 0.35; 'sometimes': 0.35; 'but': 0.36; 'possible.': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'received:org': 0.37; 'things': 0.38; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'software': 0.40; 'chance': 0.60; 'ever': 0.60; 'your': 0.60; 'skip:n 10': 0.62; 'purchase': 0.66; 'warm': 0.67; 'skip:\xe2 10': 0.70; 'wish': 0.71; '_o__)': 0.84; 'pray': 0.84; 'received:125': 0.84; 'skin': 0.91; 'thing,': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Ben Finney <ben+python@benfinney.id.au> |
| Subject | Re: Context-aware return |
| Date | Fri, 11 Sep 2015 04:12:53 +1000 |
| References | <55f1c3c6$0$1659$c3e8da3$5496439d@news.astraweb.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | jigong.madmonks.org |
| X-Public-Key-ID | 0xAC128405 |
| X-Public-Key-Fingerprint | 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 |
| X-Public-Key-URL | http://www.benfinney.id.au/contact/bfinney-pubkey.asc |
| X-Post-From | Ben Finney <bignose+hates-spam@benfinney.id.au> |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
| Cancel-Lock | sha1:ElTTLdSyAqdqQgzlvZIOYKILKz4= |
| 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.326.1441908814.8327.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1441908814 news.xs4all.nl 23856 [2001:888:2000:d::a6]:54602 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:96276 |
Show key headers only | View raw
Steven D'Aprano <steve@pearwood.info> writes: > 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. > […] > > x = func() > assert x == 999 > > L = [1, 2, func(), 4] > assert L[2] == 999 > > func() > # interactive interpreter prints "Awesome" > > Is such a thing possible, and if so, how would I do it? That makes my skin creep. In the name of all the tea I've sacrificed to Python over the years, I pray this isn't possible. > If I did this thing, would people follow me down the street booing and > jeering and throwing things at me? First thing in the morning I will purchase a head of cabbage and store it in a warm place to make it rot, on the off chance you find some obscure way to achieve your benighted goal, just so I can be first in line to throw it as you pass. If ever I have to worry that some arbitrary Python function, unbenownst to me, might have a branch that will make it behave differently depending on *whether I bind a reference to its return value*, then I'll know you are sent to us as an evil spirit to make all software suck. -- \ “Nothing exists except atoms and empty space; everything else | `\ is opinion.” —Democritus | _o__) | Ben Finney
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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