Python Newbie

Joshua Landau joshua.landau.ws at gmail.com
Sun Feb 24 17:51:16 EST 2013


On 24 February 2013 22:08, Chris Angelico <rosuav at gmail.com> wrote:

> On Mon, Feb 25, 2013 at 8:35 AM, Joshua Landau
> <joshua.landau.ws at gmail.com> wrote:
> > def solve_quadratic(a, b, c):
> > """Solve a quadratic equation of the form ax² + bx + c = 0
> >
> > The result will be a tuple of the two results; the results can be equal
> if
> > the determinant is 0.
> > This supports imaginary results for if the determinant is negative."""
> > ...
> > results = [top/(2*a) for top in fraction_tops]
>
> Yeah, I think we know which one is the more readable... Just to
> nit-pick a little though, that returns a list when its docstring says
> it'll return a tuple :)
>

Good catch.


> Other than that (which is probably better solved by changing the docs
> than the code), the only change I'd make would be to ditch the
> fraction_tops temporary (and to throw out some of the comments that
> serve only to reexpress the code that immediately follows them, though
> for a demo they're entirely appropriate).
>

I knew someone would critique it. It's an exaggerated demo for foo's sake.
Heck, who even uses a function like that (or uses unicode in comments :P)?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130224/29344911/attachment.html>


More information about the Python-list mailing list