The problem is that everyone has a different idea about what is a "basic operation" is. If everything that anyone considered a "basic operation" was included as a built-in then the builtins would be unusably large. That is why we have the standard library, so people can easily do "basic operation" without having to install additional software while not making the builtins so large as to be unmanageable. On Thu, Dec 26, 2019, 09:23 Kemal Diri <kemal.diri@sewan.fr> wrote:
Thank you Sebastien for your contribution. I wasn't clear maybe. My idea is being able to use avg function without importing any library.
The reason to propose this evolution is basically,
- If I can do sum(list) and len(list), would be better to do avg(list) (since I know sum and len of my list), - No need to import a library for this basic operation (even it costs nothing) so I won't consume a line.
Cordialement/Regards Kemal DIRI
------------------------------ *De :* Sebastian Kreft <skreft@gmail.com> *Envoyé :* jeudi 26 décembre 2019 15:07 *À :* Kemal Diri <kemal.diri@sewan.fr> *Cc :* python-ideas@python.org <python-ideas@python.org>; kemaldiri@gmail.com <kemaldiri@gmail.com> *Objet :* Re: [Python-ideas] AVG Function as Built-in
Just use `from statistics import mean as avg` (see https://docs.python.org/3/library/statistics.html#statistics.mean).
Please provide some justification on why do you think it's desirable to make `avg` a builtin, considering, that doing so is a backwards incompatible change due to the more than likely name clash.
On Thu, Dec 26, 2019 at 10:52 AM Kemal Diri <kemal.diri@sewan.fr> wrote:
Hello,
I think it would be nice to introduce an avg method for lists as a built-in function in python3. To get average of the list, I need to use some libs (eg numpy). In my opinion, if I can get *sum* of the list, I should get *avg *also in a same way.
For ex [python3]:
l = [5, 9, 7,] ... ... import numpy as np ... print(np.mean(l)) 7.0 sum(l) / len(l) 7.0 avg(l) Traceback (most recent call last): File "<input>", line 1, in <module> NameError: name 'avg' is not defined
Cordialement/Regards Kemal DIRI
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/NQB6VU... Code of Conduct: http://python.org/psf/codeofconduct/
-- Sebastian Kreft _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/NM5G2B... Code of Conduct: http://python.org/psf/codeofconduct/