Path: csiph.com!goblin3!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail 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; 'else:': 0.03; 'debug': 0.04; 'cc:addr:python-list': 0.09; '[1,': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'interpreter': 0.15; 'result.': 0.15; '999': 0.16; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'func():': 0.16; 'message-id:@fido.openend.se': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'why,': 0.16; 'laura': 0.18; '2015': 0.20; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; 'sep': 0.22; 'this:': 0.23; 'fri,': 0.27; 'function': 0.28; 'prints': 0.29; 'received:se': 0.29; 'cc:no real name:2**1': 0.29; 'print': 0.30; 'getting': 0.33; 'me?': 0.34; 'this?': 0.34; 'so,': 0.35; 'ahead': 0.35; 'possible,': 0.35; 'something': 0.35; "isn't": 0.35; 'problem.': 0.35; 'sometimes': 0.35; 'there': 0.36; 'subject:: ': 0.37; 'charset:us-ascii': 0.37; 'things': 0.38; 'doing': 0.38; 'why': 0.39; 'goes': 0.39; 'subject:-': 0.39; 'some': 0.40; 'header:Message-Id:1': 0.61; '+1000,': 0.84; '>def': 0.84; '>if': 0.84; 'header:In-reply-to:1': 0.84; 'procedure:': 0.84; 'thing,': 0.93 To: "Steven D'Aprano" cc: python-list@python.org, lac@openend.se From: Laura Creighton Subject: Re: Context-aware return In-reply-to: <55f1c3c6$0$1659$c3e8da3$5496439d@news.astraweb.com> References: <55f1c3c6$0$1659$c3e8da3$5496439d@news.astraweb.com> Comments: In-reply-to "Steven D'Aprano" message dated "Fri, 11 Sep 2015 03:54:14 +1000." MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30822.1441910449.1@fido> Date: Thu, 10 Sep 2015 20:40:49 +0200 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [82.96.5.2]); Thu, 10 Sep 2015 20:40:57 +0200 (CEST) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1441910470 news.xs4all.nl 23745 [2001:888:2000:d::a6]:52210 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96286 In a message of Fri, 11 Sep 2015 03:54:14 +1000, "Steven D'Aprano" writes: >def func(): > do_stuff() > if procedure: # FIXME what goes here??? > return "Awesome" > else: > return 999 > >Now I can do this: > > >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? Why, why, why do you want such a horrid thing? I have an function that isn't always doing what I want. I make a reference to it, so I can print it from time to time, and do some other things to try to see why sometimes I am getting an unwanted result. I can no longer debug my problem. You are seriously proposing this? >If I did this thing, would people follow me down the street booing and >jeering and throwing things at me? I might start ahead of time, just for thinking of it ... There has got to be a better way to get what you want -- or perhaps for you to want something saner. Laura