On Tue, Apr 07, 2015 at 08:47:25AM -0400, Ben Hoyt wrote:
> > My own preference would be:
> >
> > def foo(x):
> > if x >= 0:
> > return math.sqrt(x)
> > return None
>
> Kind of getting into the weeds here, but I would always invert this to
> "return errors early, an
Talk about hijacking an unrelated thread... :-(
Though there's maybe a style rule for the ternary operator to be devised
here? :-)
On Apr 7, 2015 11:36 AM, "Stefan Behnel" wrote:
> Antoine Pitrou schrieb am 07.04.2015 um 14:26:
> > On Tue, 07 Apr 2015 03:11:30 +0100
> > Rob Cliffe wrote:
> >>
Antoine Pitrou schrieb am 07.04.2015 um 14:26:
> On Tue, 07 Apr 2015 03:11:30 +0100
> Rob Cliffe wrote:
>>
>> On 07/04/2015 02:08, Guido van Rossum wrote:
>>> I've taken the liberty of adding the following old but good rule to
>>> PEP 8 (I was surprised to find it wasn't already there since I've
> My own preference would be:
>
> def foo(x):
> if x >= 0:
> return math.sqrt(x)
> return None
Kind of getting into the weeds here, but I would always invert this to
"return errors early, and keep the normal flow at the main indentation
level". Depends a little on w
On Tue, 07 Apr 2015 03:11:30 +0100
Rob Cliffe wrote:
>
> On 07/04/2015 02:08, Guido van Rossum wrote:
> > I've taken the liberty of adding the following old but good rule to
> > PEP 8 (I was surprised to find it wasn't already there since I've
> > lived by this for ages):
> >
> > *
> >
> >
On Tue, Apr 07, 2015 at 03:11:30AM +0100, Rob Cliffe wrote:
> As a matter of interest, how far away from mainstream am I in
> preferring, *in this particular example* (obviously it might be
> different for more complicated computation),
>
> def foo(x):
> return math.sqrt(x) if x >=
On 07/04/2015 02:08, Guido van Rossum wrote:
I've taken the liberty of adding the following old but good rule to
PEP 8 (I was surprised to find it wasn't already there since I've
lived by this for ages):
*
Be consistent in return statements. Either all return statements
in a functi
On Apr 06, 2015, at 06:08 PM, Guido van Rossum wrote:
>I've taken the liberty of adding the following old but good rule to PEP 8
>(I was surprised to find it wasn't already there since I've lived by this
>for ages):
>
> Be consistent in return statements. Either all return statements in a
> fu
I've taken the liberty of adding the following old but good rule to PEP 8
(I was surprised to find it wasn't already there since I've lived by this
for ages):
-
Be consistent in return statements. Either all return statements in a
function should return an expression, or none of them sh