Here's a function found online (I'm too lazy to write my own, but it would
be mostly the same). Tell me how keyword arguments could help this... Or
WHAT names you'd give.


   1. def quad(a,b,c):
   2. """solves quadratic equations of the form
   3. aX^2+bX+c, inputs a,b,c,
   4. works for all roots(real or complex)"""
   5. root=b**2-4*a*c
   6. if root <0:
   7. root=abs(complex(root))
   8. j=complex(0,1)
   9. x1=(-b+j+sqrt(root))/2*a
   10. x2=(-b-j+sqrt(root))/2*a
   11. return x1,x2
   12. else:
   13. x1=(-b+sqrt(root))/2*a
   14. x2=(-b-sqrt(root))/2*a
   15. return x1,x2


After that, explain why forcing all callers to name their local variables
a, b, c would be a good thing.

On Fri, Sep 7, 2018, 12:18 PM Robert Vanden Eynde <robertv...@gmail.com>
wrote:

>
>> I disagree.  Keyword arguments are a fine and good thing, but they are
>> best used for optional arguments IMHO.  Verbosity for the sake of
>> verbosity is not a good thing.
>
>
> I disagree, when you have more than one parameter it's sometimes
> complicated to remember the order. Therefore, when you name your args, you
> have way less probability of passing the wrong variable, even with only one
> arg.
>
> Verbosity adds redundancy, so that both caller and callee are sure they
> mean the same thing.
>
> That's why Java has types everywhere, such that the "declaration part" and
> the "use" part agree on the same idea (same type).
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to