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 <skr...@gmail.com> Envoyé : jeudi 26 décembre 2019 15:07 À : Kemal Diri <kemal.d...@sewan.fr> Cc : python-ideas@python.org <python-ideas@python.org>; kemald...@gmail.com <kemald...@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.d...@sewan.fr<mailto:kemal.d...@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<mailto:python-ideas@python.org> To unsubscribe send an email to python-ideas-le...@python.org<mailto:python-ideas-le...@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/NQB6VU6QSC253JT2SWUO3IWCZ3IG36XP/ 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-le...@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/NM5G2B3VESHFB74G5ZWJBXHIFLBRW3HM/ Code of Conduct: http://python.org/psf/codeofconduct/