Re: Why isn't there a built-in product()?

2022-07-07 Thread Oscar Benjamin
On Thu, 7 Jul 2022 at 22:55, Michael F. Stemper
 wrote:
>
> sum() is wonderful.
>
>   >>> nums = [1,2,3]
>   >>> sum(nums)
>   6
>   >>> product(nums)
>   Traceback (most recent call last):
> File "", line 1, in 
>   NameError: name 'product' is not defined
>   >>>
>
> I understand that there is no product() or prod(). Does anybody
> here know why that was not included in the language? It seems
> as if it would be useful, so there must have been some rationale
> for that decision.

There is math.prod:

  >>> from math import prod
  >>> prod([1, 2, 3, 4])
  24

https://docs.python.org/3/library/math.html#math.prod

--
Oscar
-- 
https://mail.python.org/mailman/listinfo/python-list


Why isn't there a built-in product()?

2022-07-07 Thread Michael F. Stemper

sum() is wonderful.

 >>> nums = [1,2,3]
 >>> sum(nums)
 6
 >>> product(nums)
 Traceback (most recent call last):
   File "", line 1, in 
 NameError: name 'product' is not defined
 >>>

I understand that there is no product() or prod(). Does anybody
here know why that was not included in the language? It seems
as if it would be useful, so there must have been some rationale
for that decision.

--
Michael F. Stemper
87.3% of all statistics are made up by the person giving them.
--
https://mail.python.org/mailman/listinfo/python-list


Python 3.9 pidfd_open

2022-07-07 Thread Weatherby,Gerard
python introduced os.pidfd_open(), which works as documented.

My development environment, PyCharm, complains about it being undefined.

Should it be in https://raw.githubusercontent.com/python/cpython/3.9/Lib/os.py ?

--
Gerard Weatherby | Application Architect
NMRbox | NAN | Department of Molecular Biology and Biophysics | UConn Health
263 Farmington Avenue, Farmington, CT 06030-6406
uchc.edu
-- 
https://mail.python.org/mailman/listinfo/python-list