PEP 308: some candidate uses cases from live code

Peter Hansen peter at engcorp.com
Mon Feb 10 13:06:52 EST 2003


Kyler Laird wrote:
> 
> claird at lairds.com (Cameron Laird) writes:
> 
> >No partial-wink disclaimers?  Myself, I think casual maintainers
> >(and that *is* our target audience as Real-Life Programmers,
> >right?) will find
> >  sy = d0.year
> >  if d0.month < 7:
> >      sy -= 1
> >best serves.
> 
> Anyone want to claim that this is preferable for some?
>         if d0.month < 7:
>                 sy = d0.year - 1
>         else:
>                 sy = d0.year
> 
> I cringe at the duplication of "d0.year" but I've been
> teaching Scheme recently and noticed that students seem
> very comfortable saying "If this is the case, then the
> answer is this, otherwise..." instead of "Always do this
> and then if whatever, modify the result."
> 
> I'm not sure how I feel about it.

Speaking purely from a Test-Driven Development point of view,
that approach is *not* preferable because it involves 
duplication (of d0.year in this case) whereas the original
form does not.

But I will certainly stand up and claim "this is preferable
for some"... just not for me. ;-)


-Peter




More information about the Python-list mailing list