Re: Feature suggestion -- return if true

2017-08-21 Thread Ian Kelly
On Mon, Aug 21, 2017 at 8:39 AM, alister via Python-list wrote: > On Mon, 21 Aug 2017 05:44:53 -0700, jek wrote: >> This is a very old post, but since I just though I would like a >> conditional return like this, and checked for previous proposals, I >> thought I'd give my

Re: Feature suggestion -- return if true

2017-08-21 Thread alister via Python-list
On Mon, 21 Aug 2017 05:44:53 -0700, jek wrote: > This is a very old post, but since I just though I would like a > conditional return like this, and checked for previous proposals, I > thought I'd give my opinion. > > Unfortunately only about 8 of the 67 replies actually answer the > question,

Re: Feature suggestion -- return if true

2017-08-21 Thread jek
This is a very old post, but since I just though I would like a conditional return like this, and checked for previous proposals, I thought I'd give my opinion. Unfortunately only about 8 of the 67 replies actually answer the question, and there isn't any overwhelming consensus to if a

Re: Feature suggestion -- return if true

2011-04-21 Thread Thomas Rachel
Am 13.04.2011 01:06, schrieb Ethan Furman: -- def func(): -- var1 = something() -- var2 = something_else('this') -- return? var1.hobgle(var2) -- var3 = last_resort(var1) -- return var3.wiglat(var2) This makes me think of a decorator which can mimic the wantend behaviour: def getfirst(f):

Re: Feature suggestion -- return if true

2011-04-19 Thread Jussi Piitulainen
Gregory Ewing writes: Chris Angelico wrote: Question: How many factorial functions are implemented because a program needs to know what n! is, and how many are implemented to demonstrate recursion (or to demonstrate the difference between iteration and recursion)? :) (I can't get to

Re: Feature suggestion -- return if true

2011-04-19 Thread Chris Angelico
On Tue, Apr 19, 2011 at 4:42 PM, Jussi Piitulainen jpiit...@ling.helsinki.fi wrote: Factorials become an interesting demonstration of recursion when done well. There's a paper by Richard J. Fateman, citing Peter Luschny: http://www.cs.berkeley.edu/~fateman/papers/factorial.pdf

Re: Feature suggestion -- return if true

2011-04-18 Thread Aahz
In article mailman.461.1303043638.9059.python-l...@python.org, D'Arcy J.M. Cain da...@druid.net wrote: On Sun, 17 Apr 2011 16:21:53 +1200 Gregory Ewing greg.ew...@canterbury.ac.nz wrote: My idiom for fetching from a cache looks like this: def get_from_cache(x): y = cache.get(x)

Re: Feature suggestion -- return if true

2011-04-18 Thread Gregory Ewing
Chris Angelico wrote: Question: How many factorial functions are implemented because a program needs to know what n! is, and how many are implemented to demonstrate recursion (or to demonstrate the difference between iteration and recursion)? :) A related question is how often factorial

Re: Feature suggestion -- return if true

2011-04-17 Thread Steven D'Aprano
On Sun, 17 Apr 2011 16:21:53 +1200, Gregory Ewing wrote: Chris Angelico wrote: def fac(n): # attempt to get from a cache return? cache[n] # not in cache, calculate the value ret=1 if n=1 else fac(n-1)*n # and cache and return it cache[n]=ret; return ret My

Re: Feature suggestion -- return if true

2011-04-17 Thread Chris Angelico
On Sun, Apr 17, 2011 at 6:45 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sun, 17 Apr 2011 16:21:53 +1200, Gregory Ewing wrote: Chris Angelico wrote: def fac(n):     # attempt to get from a cache     return? cache[n]     # not in cache, calculate the value     ret=1

Re: Feature suggestion -- return if true

2011-04-17 Thread Martin v. Loewis
be expanded to _temp = expr if _temp: return _temp This could be simplified to just: return expr or None No, it can't be simplified in this way. If there is code after that snippet, then it will get executed in the original version if _temp is false, but won't get executed in

Re: Feature suggestion -- return if true

2011-04-17 Thread D'Arcy J.M. Cain
On Sun, 17 Apr 2011 16:21:53 +1200 Gregory Ewing greg.ew...@canterbury.ac.nz wrote: My idiom for fetching from a cache looks like this: def get_from_cache(x): y = cache.get(x) if not y: y = compute_from(x) cache[x] = y return y I prefer not to create and

Re: Feature suggestion -- return if true

2011-04-17 Thread Steven D'Aprano
On Sun, 17 Apr 2011 08:33:47 -0400, D'Arcy J.M. Cain wrote: On Sun, 17 Apr 2011 16:21:53 +1200 Gregory Ewing greg.ew...@canterbury.ac.nz wrote: My idiom for fetching from a cache looks like this: def get_from_cache(x): y = cache.get(x) if not y: y = compute_from(x)

Re: Feature suggestion -- return if true

2011-04-17 Thread Steven D'Aprano
On Sun, 17 Apr 2011 19:07:03 +1000, Chris Angelico wrote: If there's the possibility of _ANY_ value coming back from the computation, then it would need to be done as: if x in cache: return cache[x] Or you can create a sentinel value that is guaranteed to never appear anywhere else:

Re: Feature suggestion -- return if true

2011-04-17 Thread Greg Ewing
D'Arcy J.M. Cain wrote: On Sun, 17 Apr 2011 16:21:53 +1200 Gregory Ewing greg.ew...@canterbury.ac.nz wrote: def get_from_cache(x): y = cache.get(x) if not y: y = compute_from(x) cache[x] = y return y I prefer not to create and destroy objects needlessly. How does

Re: Feature suggestion -- return if true

2011-04-17 Thread James Mills
On Sun, Apr 17, 2011 at 8:03 PM, Martin v. Loewis mar...@v.loewis.de wrote: No, it can't be simplified in this way. If there is code after that snippet, then it will get executed in the original version if _temp is false, but won't get executed in your simplification. Martin, we've been over

Re: Feature suggestion -- return if true

2011-04-17 Thread Gregory Ewing
Steven D'Aprano wrote: I'm sure you realise that that snippet needlessly recalculates any cached result that happens to be false, but others reading might not. I only use it as written when I'm dealing with types that don't have false values. If I did need to cache such a type, I would use a

Re: Feature suggestion -- return if true

2011-04-17 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Chris Angelico wrote: snip Sure. In my (somewhat contrived) example of factorials, that's going to be true (apart from 0! = 0); and if the function returns a string or other object rather than an integer, same thing. If there's the Just to be pedantic, by any

Re: Feature suggestion -- return if true

2011-04-17 Thread Chris Angelico
On Mon, Apr 18, 2011 at 12:04 PM, Dave Angel da...@ieee.org wrote: On 01/-10/-28163 02:59 PM, Chris Angelico wrote:  snip Sure. In my (somewhat contrived) example of factorials, that's going to be true (apart from 0! = 0); and if the function returns a string or other object rather than an

Re: Feature suggestion -- return if true

2011-04-16 Thread Gregory Ewing
Chris Angelico wrote: def fac(n): # attempt to get from a cache return? cache[n] # not in cache, calculate the value ret=1 if n=1 else fac(n-1)*n # and cache and return it cache[n]=ret; return ret My idiom for fetching from a cache looks like this: def

Re: Feature suggestion -- return if true

2011-04-16 Thread Chris Angelico
On Sun, Apr 17, 2011 at 2:21 PM, Gregory Ewing greg.ew...@canterbury.ac.nz wrote: My idiom for fetching from a cache looks like this:  def get_from_cache(x):    y = cache.get(x)    if not y:      y = compute_from(x)      cache[x] = y    return y which doesn't require any conditional

Re: Feature suggestion -- return if true

2011-04-13 Thread Teemu Likonen
* 2011-04-12T13:26:48-07:00 * Chris Rebert wrote: I think Ben Yahtzee Croshaw's comments on open-world sandbox video games (of all things) have a lot of applicability to why allowing full-on macros can be a bad idea. IOW, a language is usually better for having such discussions and having a

Re: Feature suggestion -- return if true

2011-04-12 Thread Nobody
On Tue, 12 Apr 2011 13:01:43 +1000, James Mills wrote: That's still not equivalent. return expr or None will always terminate the function. The OP's request was for something which would terminate the function if and only if expr is non-false. The OP did not state this at all. There was

Re: Feature suggestion -- return if true

2011-04-12 Thread James Mills
On Tue, Apr 12, 2011 at 4:08 PM, Nobody nob...@nowhere.com wrote: It should be abundantly clear that this only returns if the expression is considered true, otherwise it continues on to the following statements. Uggh come on guys. We've been over this. You cannot make that assumption. cheers

Re: Feature suggestion -- return if true

2011-04-12 Thread Paul Rubin
zildjohn01 zildjoh...@gmail.com writes: _temp = expr if _temp: return _temp I'm trying to figure out a context where you'd even want that, and I'm thinking that maybe it's some version of a repeat-until loop? Python doesn't have repeat-until and it's been proposed a few times. --

Re: Feature suggestion -- return if true

2011-04-12 Thread Steven D'Aprano
On Tue, 12 Apr 2011 16:21:43 +1000, James Mills wrote: On Tue, Apr 12, 2011 at 4:08 PM, Nobody nob...@nowhere.com wrote: It should be abundantly clear that this only returns if the expression is considered true, otherwise it continues on to the following statements. Uggh come on guys.

Re: Feature suggestion -- return if true

2011-04-12 Thread scattered
On Apr 12, 2:21 am, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Apr 12, 2011 at 4:08 PM, Nobody nob...@nowhere.com wrote: It should be abundantly clear that this only returns if the expression is considered true, otherwise it continues on to the following statements. Uggh come

Re: Feature suggestion -- return if true

2011-04-12 Thread John Roth
On Apr 12, 12:58 am, Paul Rubin no.em...@nospam.invalid wrote: zildjohn01 zildjoh...@gmail.com writes:     _temp = expr     if _temp: return _temp I'm trying to figure out a context where you'd even want that, and I'm thinking that maybe it's some version of a repeat-until loop?  Python

Re: Feature suggestion -- return if true

2011-04-12 Thread Grant Edwards
On 2011-04-12, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Apr 12, 2011 at 12:18 PM, Grant Edwards invalid@invalid.invalid wrote: You stated that ??return? expr was equivalent to ??return expr or None This is _not_ what I said. Quoting from my earlier post: return?

Re: Feature suggestion -- return if true

2011-04-12 Thread Grant Edwards
On 2011-04-12, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Apr 12, 2011 at 12:44 PM, Chris Angelico ros...@gmail.com wrote: That's still not equivalent. return expr or None will always terminate the function. The OP's request was for something which would terminate the function if

Re: Feature suggestion -- return if true

2011-04-12 Thread Grant Edwards
On 2011-04-12, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Apr 12, 2011 at 4:08 PM, Nobody nob...@nowhere.com wrote: It should be abundantly clear that this only returns if the expression is considered true, otherwise it continues on to the following statements. Uggh come on guys.

Re: Feature suggestion -- return if true

2011-04-12 Thread Colin J. Williams
On 12-Apr-11 06:55 AM, scattered wrote: On Apr 12, 2:21 am, James Millsprolo...@shortcircuit.net.au wrote: On Tue, Apr 12, 2011 at 4:08 PM, Nobodynob...@nowhere.com wrote: It should be abundantly clear that this only returns if the expression is considered true, otherwise it continues on to

Re: Feature suggestion -- return if true

2011-04-12 Thread Westley Martínez
On Tue, 2011-04-12 at 12:44 +1000, Chris Angelico wrote: On Tue, Apr 12, 2011 at 12:20 PM, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails jason.swa...@gmail.com wrote: This is only true if n 5. Otherwise, the first returns None and the

Re: Feature suggestion -- return if true

2011-04-12 Thread scattered
On Apr 12, 10:05 am, Westley Martínez aniko...@gmail.com wrote: On Tue, 2011-04-12 at 12:44 +1000, Chris Angelico wrote: On Tue, Apr 12, 2011 at 12:20 PM, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails jason.swa...@gmail.com wrote:

Re: Feature suggestion -- return if true

2011-04-12 Thread Mel
Paul Rubin wrote: zildjohn01 zildjoh...@gmail.com writes: _temp = expr if _temp: return _temp I'm trying to figure out a context where you'd even want that, and I'm thinking that maybe it's some version of a repeat-until loop? Python doesn't have repeat-until and it's been

Re: Feature suggestion -- return if true

2011-04-12 Thread Teemu Likonen
* 2011-04-12T10:27:55+10:00 * James Mills wrote: On Tue, Apr 12, 2011 at 9:17 AM, zildjohn01 zildjoh...@gmail.com wrote: This is an idea I've had bouncing around in my head for a long time now. I propose the following syntax: Maybe this is more appropriare for the python-ideas list ?    

Re: Feature suggestion -- return if true

2011-04-12 Thread Ian Kelly
On Tue, Apr 12, 2011 at 12:00 PM, Teemu Likonen tliko...@iki.fi wrote: I'm a simple Lisp guy who wonders if it is be possible to add some kind of macros to the language. Then features like this could be added by anybody. Lisp people do this all the time and there is no need for feature

Re: Feature suggestion -- return if true

2011-04-12 Thread zildjohn01
Wow. Two dozen replies, the majority of which are arguing over whether the end of my snippet is reachable. I thought the behavior of if statements was well-established by this point. Regardless of James Mills's coding prowess, I suppose I should follow his advice and repost this to the

Re: Feature suggestion -- return if true

2011-04-12 Thread Ian Kelly
On Tue, Apr 12, 2011 at 12:25 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Tue, Apr 12, 2011 at 12:00 PM, Teemu Likonen tliko...@iki.fi wrote: I'm a simple Lisp guy who wonders if it is be possible to add some kind of macros to the language. Then features like this could be added by anybody.

Re: Feature suggestion -- return if true

2011-04-12 Thread Paul Rudin
Teemu Likonen tliko...@iki.fi writes: I'm a simple Lisp guy who wonders if it is be possible to add some kind of macros to the language... As a (now somewhat lapsed) long-time lisp programmer I sympathise with the sentiment, but suspect that it's not going to gain serious traction in python

Re: Feature suggestion -- return if true

2011-04-12 Thread Terry Reedy
On 4/12/2011 2:25 PM, zildjohn01 wrote: Wow. Two dozen replies, the majority of which are arguing over whether the end of my snippet is reachable. I thought the behavior of if statements was well-established by this point. Regardless of James Mills's coding prowess, I suppose I should follow

Re: Feature suggestion -- return if true

2011-04-12 Thread Neil Cerutti
On 2011-04-12, Ian Kelly ian.g.ke...@gmail.com wrote: Flow-control macros were suggested as part of PEP 343, but they were rejected by Guido based on this rant: http://blogs.msdn.com/b/oldnewthing/archive/2005/01/06/347666.aspx Flow control macros don't seem to create problems that exceptions

Re: Feature suggestion -- return if true

2011-04-12 Thread Neil Cerutti
On 2011-04-12, Neil Cerutti ne...@norwich.edu wrote: On 2011-04-12, Ian Kelly ian.g.ke...@gmail.com wrote: Flow-control macros were suggested as part of PEP 343, but they were rejected by Guido based on this rant: http://blogs.msdn.com/b/oldnewthing/archive/2005/01/06/347666.aspx Flow

Re: Feature suggestion -- return if true

2011-04-12 Thread Chris Rebert
On Tue, Apr 12, 2011 at 11:00 AM, Teemu Likonen tliko...@iki.fi wrote: * 2011-04-12T10:27:55+10:00 * James Mills wrote: On Tue, Apr 12, 2011 at 9:17 AM, zildjohn01 zildjoh...@gmail.com wrote: This is an idea I've had bouncing around in my head for a long time now. I propose the following

Re: Feature suggestion -- return if true

2011-04-12 Thread James Mills
On Wed, Apr 13, 2011 at 6:26 AM, Chris Rebert c...@rebertia.com wrote: Paraphrasing liberally from his review of Far Cry 2: Letting the [programmer] create their own [language constructs is] always done at the expense of proper [orthogonality, elegance, and coherence]. Maybe sometimes I don't

Re: Feature suggestion -- return if true

2011-04-12 Thread Westley Martínez
On Tue, 2011-04-12 at 07:58 -0700, scattered wrote: On Apr 12, 10:05 am, Westley Martínez aniko...@gmail.com wrote: On Tue, 2011-04-12 at 12:44 +1000, Chris Angelico wrote: On Tue, Apr 12, 2011 at 12:20 PM, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Apr 12, 2011 at 12:18

Re: Feature suggestion -- return if true

2011-04-12 Thread Chris Angelico
On Wed, Apr 13, 2011 at 8:45 AM, Westley Martínez aniko...@gmail.com wrote: I don't think that this is equivalent. The OP's original idea doesn't involve a loop, but this does - how could that be equivalent? Not OP's idea, Angelico's. I didn't actually advocate a loop, but that method could

Re: Feature suggestion -- return if true

2011-04-12 Thread Ethan Furman
James Mills wrote: Are we done with this discussion yet ? :) *sigh* It was a slow day yesterday and I have a funny feeling it's going to be the same today! Regardless of anyone's subjective opinions as to what was clear - I still stand by what I said. I think I see your point -- the OP said:

Re: Feature suggestion -- return if true

2011-04-12 Thread James Mills
On Wed, Apr 13, 2011 at 9:06 AM, Ethan Furman et...@stoneleaf.us wrote: I think I see your point -- the OP said: --    _temp = expr --    if _temp: return _temp which is where you're getting --    return _temp or None However, most everyone ('cept you, it seems! ;) understood that there

Re: Feature suggestion -- return if true

2011-04-12 Thread Westley Martínez
On Tue, 2011-04-12 at 16:06 -0700, Ethan Furman wrote: James Mills wrote: Are we done with this discussion yet ? :) *sigh* It was a slow day yesterday and I have a funny feeling it's going to be the same today! Regardless of anyone's subjective opinions as to what was clear - I still

Re: Feature suggestion -- return if true

2011-04-12 Thread Ethan Furman
Westley Martínez wrote: On Tue, 2011-04-12 at 16:06 -0700, Ethan Furman wrote: -- def func(): -- var1 = something() -- var2 = something_else('this') -- return? var1.hobgle(var2) -- var3 = last_resort(var1) -- return var3.wiglat(var2) The question mark makes the programmer

Re: Feature suggestion -- return if true

2011-04-12 Thread Steven D'Aprano
On Tue, 12 Apr 2011 16:48:31 -0700, Ethan Furman wrote: Westley Martínez wrote: On Tue, 2011-04-12 at 16:06 -0700, Ethan Furman wrote: -- def func(): -- var1 = something() -- var2 = something_else('this') -- return? var1.hobgle(var2) -- var3 = last_resort(var1) --

Re: Feature suggestion -- return if true

2011-04-12 Thread Ethan Furman
Steven D'Aprano wrote: On Tue, 12 Apr 2011 16:48:31 -0700, Ethan Furman wrote: Westley Martínez wrote: On Tue, 2011-04-12 at 16:06 -0700, Ethan Furman wrote: -- def func(): -- var1 = something() -- var2 = something_else('this') -- return? var1.hobgle(var2) -- var3 =

Re: Feature suggestion -- return if true

2011-04-12 Thread Chris Angelico
On Wed, Apr 13, 2011 at 12:42 PM, Ethan Furman et...@stoneleaf.us wrote: The indentation for return and raise is the next coded line.  List comps and gen exps are basically uber-functions, and regardless of how you categorize them when they finish it is easy to see where control goes to next

Re: Feature suggestion -- return if true

2011-04-12 Thread James Mills
On Wed, Apr 13, 2011 at 1:00 PM, Chris Angelico ros...@gmail.com wrote: def foo(param):    resource=malloc(5) # Shtarker, zis is Python! We don't malloc here!    if not resource: return 0    resource[param]=5    del resource    return 1 In Python this can probably be done and perhaps is

Re: Feature suggestion -- return if true

2011-04-12 Thread alex23
zildjohn01 zildjoh...@gmail.com wrote: Regardless of James Mills's coding prowess[...] James is the sole dev of a very handy elegant event framework: https://bitbucket.org/prologic/circuits/ Can you point out any equivalent achievements so we can compare? And make sure to carry that attitude

Feature suggestion -- return if true

2011-04-11 Thread zildjohn01
This is an idea I've had bouncing around in my head for a long time now. I propose the following syntax: return? expr be expanded to _temp = expr if _temp: return _temp It's a pattern I use all the time in my code, and although it's a bit unorthodox, IMO it's concise, readable, and

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 9:17 AM, zildjohn01 zildjoh...@gmail.com wrote: This is an idea I've had bouncing around in my head for a long time now. I propose the following syntax: Maybe this is more appropriare for the python-ideas list ?    return? expr This syntax does not fit well within

Re: Feature suggestion -- return if true

2011-04-11 Thread Chris Angelico
On Tue, Apr 12, 2011 at 10:27 AM, James Mills prolo...@shortcircuit.net.au wrote: This could be simplified to just: return expr or None And more to the point... If your calee is relying on the result of this function, just returning the evaluation of expr is enough. I'm thinking here that

Re: Feature suggestion -- return if true

2011-04-11 Thread Chris Angelico
On Tue, Apr 12, 2011 at 10:46 AM, Chris Angelico ros...@gmail.com wrote: def fac(n):    return cache[n] or (cache[n]=1 if n=1 else fac(n-1)*n) Hmm. The function-call version of dictionary assignment IS legal in an expression, but it's getting stupid... def fac(n): return cache.get(n) or

Re: Feature suggestion -- return if true

2011-04-11 Thread Grant Edwards
On 2011-04-12, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Apr 12, 2011 at 9:17 AM, zildjohn01 zildjoh...@gmail.com wrote: This is an idea I've had bouncing around in my head for a long time now. I propose the following syntax: Maybe this is more appropriare for the python-ideas

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 11:44 AM, Grant Edwards invalid@invalid.invalid wrote: How is that the same?  return? something()                  return something() or None  return? somethingelse()              return somethingelse() or None  log(didn't find an answer)         log(didn't find an

Re: Feature suggestion -- return if true

2011-04-11 Thread Jason Swails
On Mon, Apr 11, 2011 at 7:12 PM, James Mills prolo...@shortcircuit.net.auwrote: Are you saying the two snippets above are equivalent? def foo(n): x = n 5 if x: return x is functionally equivalent to: def foo(n): return n 5 This is only true if n 5. Otherwise,

Re: Feature suggestion -- return if true

2011-04-11 Thread Grant Edwards
On 2011-04-12, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Apr 12, 2011 at 11:44 AM, Grant Edwards invalid@invalid.invalid wrote: How is that the same? ??return? something() ?? ?? ?? ?? ?? ?? ?? ?? ??return something() or None ??return? somethingelse() ?? ?? ?? ?? ?? ?? ??return

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails jason.swa...@gmail.com wrote: This is only true if n 5.  Otherwise, the first returns None and the second returns False. Which is why I said: return expr or None But hey let's argue the point to death! cheers James -- -- James Mills -- --

Re: Feature suggestion -- return if true

2011-04-11 Thread Zero Piraeus
: This is only true if n 5.  Otherwise, the first returns None and the second returns False. Which is why I said: return expr or None But hey let's argue the point to death! Ok ;-) I think the point is that OP doesn't want to return *at all* if expr is False - presumably because there

Re: Feature suggestion -- return if true

2011-04-11 Thread Chris Angelico
On Tue, Apr 12, 2011 at 12:20 PM, James Mills prolo...@shortcircuit.net.au wrote: On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails jason.swa...@gmail.com wrote: This is only true if n 5.  Otherwise, the first returns None and the second returns False. Which is why I said: return expr or None

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 12:18 PM, Grant Edwards invalid@invalid.invalid wrote: You stated that  return? expr was equivalent to  return expr or None This is _not_ what I said. Quoting from my earlier post: return? expr This syntax does not fit well within python ideology. be

Re: Feature suggestion -- return if true

2011-04-11 Thread Chris Angelico
On Tue, Apr 12, 2011 at 12:43 PM, Zero Piraeus sche...@gmail.com wrote:  return? expr isn't very pythonic - so how about one of these?  return expr if True  return expr else continue I kid, I kid ... Or: if expr: return it Actually, I'm not sure how stupid an idea that is. Inside an

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 12:43 PM, Zero Piraeus sche...@gmail.com wrote: I think the point is that OP doesn't want to return *at all* if expr is False - presumably because there are further statements after the proposed 'conditional' return. If that's the case then we're all making assumptions

Re: Feature suggestion -- return if true

2011-04-11 Thread James Mills
On Tue, Apr 12, 2011 at 12:44 PM, Chris Angelico ros...@gmail.com wrote: That's still not equivalent. return expr or None will always terminate the function. The OP's request was for something which would terminate the function if and only if expr is non-false. The OP did not state this at