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


Groups > comp.lang.python > #96286

Re: Context-aware return

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 <lac@openend.se>
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" <steve@pearwood.info>
cc python-list@python.org, lac@openend.se
From Laura Creighton <lac@openend.se>
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" <steve@pearwood.info> 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 <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.334.1441910470.8327.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

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