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> 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-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/3P4SXG4VFWDZBBGBQMNEA6BVVVAVE7T7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to