On Mon, Apr 11, 2011 at 7:12 PM, James Mills <prolo...@shortcircuit.net.au>wrote:
> > > 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, the first returns None and the second returns False. >>> def foo(n): ... x = n < 5 ... if x: return x ... >>> def foo1(n): ... return n < 5 ... >>> foo(4) True >>> foo1(4) True >>> foo(6) >>> foo1(6) False >>> --Jason
-- http://mail.python.org/mailman/listinfo/python-list