[Python-ideas] Re: AVG Function as Built-in

2019-12-29 Thread Steven D'Aprano
On Thu, Dec 26, 2019 at 05:51:09PM -, Marco Sulla via Python-ideas wrote: > Stephen J. Turnbull wrote: > > > from statistics import mean > > > sum([1e16,1,1])/3 == 1e16/3# surprise! > > > True > > > mean([1e16,1,1]) == 1e16/3 > > > False > > > Regards, > > Python 3.9.0a0 (heads/master-

[Python-ideas] Re: AVG Function as Built-in

2019-12-26 Thread Todd
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

[Python-ideas] Re: AVG Function as Built-in

2019-12-26 Thread Andrew Barnert via Python-ideas
On Dec 26, 2019, at 05:54, Kemal Diri 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). You don’t need a third party library like numpy; you can use sta

[Python-ideas] Re: AVG Function as Built-in

2019-12-26 Thread Marco Sulla via Python-ideas
Stephen J. Turnbull wrote: > > from statistics import mean > > sum([1e16,1,1])/3 == 1e16/3# surprise! > > True > > mean([1e16,1,1]) == 1e16/3 > > False > > Regards, Python 3.9.0a0 (heads/master-dirty:d8ca2354ed, Oct 30 2019, 20:25:01) [GCC 9.2.1 20190909] on linux Type "help", "copyright"

[Python-ideas] Re: AVG Function as Built-in

2019-12-26 Thread Marco Sulla via Python-ideas
So why only mean and not median, that's better for statistics? :D Seriously, if you want it builtin, add it to PYTHONSTARTUP: https://docs.python.org/3/using/cmdline.html#envvar-PYTHONSTARTUP from statistics import mean ___ Python-ideas mailing list

[Python-ideas] Re: AVG Function as Built-in

2019-12-26 Thread Todd
The Python standard library module 'statistics' has a "mean" function. On Thu, Dec 26, 2019, 08:54 Kemal Diri 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). >

[Python-ideas] Re: AVG Function as Built-in

2019-12-26 Thread Kemal Diri
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

[Python-ideas] Re: AVG Function as Built-in

2019-12-26 Thread Sebastian Kreft
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 li