Feature suggestion -- return if true
anikom15 at gmail.com
Wed Apr 13 00:45:11 CEST 2011
On Tue, 2011-04-12 at 07:58 -0700, scattered wrote:
> On Apr 12, 10:05 am, Westley Martínez <aniko... at 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... at shortcircuit.net.au> wrote:
> > > > On Tue, Apr 12, 2011 at 12:18 PM, Jason Swails <jason.swa... at 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!
> > > 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.
> > > Chris Angelico
> > def bs(x):
> > while not x:
> > <modify x>
> > return x
> > Am I wrong here?- Hide quoted text -
> > - Show quoted text -
> 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.
More information about the Python-list