Package: prd
Idiomatic implementation of a Python function that calculates the product of the items from an iterable.PurposeA built-in product function that would complement thesumfunction wasrejected, and the built-inmath.sumfunction does not accept iterables that contain values of non-numeric types. This library exports an idiomatic implementation (usingfunctools.reduce) of a product function that can operate on iterables that contain objects of any type for which the multiplication operation is defined (e.g., via a definition of the__mul__method).Installation and UsageThis library is available as apackage on PyPI:python-mpipinstallprdThe library can be imported in the usual ways:importprdfromprdimportprdExamplesThis library exports an idiomatic implementation of a product function (an analog of – and complement to – the built-insumfunction). This function applies the built-in multiplication operatoroperator.multo all of the items from the supplied iterable:>>>prd([1,2,3,4])24>>>prd([2])2>>>prd([1.2,3.4,5.6])22.848>>>prd([])1The function is compatible with objects for which the built-in multiplication operator is defined:>>>classvar(str):...def__mul__(self,other):...returnself+' * '+other...def__rmul__(self,other):...returnother+' * '+self>>>prd([var('b'),var('c'),var('d')],var('a'))'a * b * c * d'Thestartparameter and the elements found in the iterable can be of different types. It is only required that the output of the multiplication operation can by multiplied with the next element from the iterable:>>>prd([],'a')'a'>>>prd([1,2,3],'a')'aaaaaa'>>>prd(['a',3],2)'aaaaaa'DevelopmentAll installation and development dependencies are fully specified inpyproject.toml. Theproject.optional-dependenciesobject is used tospecify optional requirementsfor various development tasks. This makes it possible to specify additional options (such asdocs,lint, and so on) when performing installation usingpip:python-mpipinstall.[docs,lint]DocumentationThe documentation can be generated automatically from the source files usingSphinx:python-mpipinstall.[docs]cddocssphinx-apidoc-f-E--templatedir=_templates-o_source..&&makehtmlTesting and ConventionsAll unit tests are executed and their coverage is measured when usingpytest(see thepyproject.tomlfile for configuration details):python-mpipinstall.[test]python-mpytestAlternatively, all unit tests are included in the module itself and can be executed usingdoctest:pythonsrc/prd/prd.py-vStyle conventions are enforced usingPylint:python-mpipinstall.[lint]python-mpylintsrc/prdContributionsIn order to contribute to the source code, open an issue or submit a pull request on theGitHub pagefor this library.VersioningThe version number format for this library and the changes to the library associated with version number increments conform withSemantic Versioning 2.0.0.PublishingThis library can be published as apackage on PyPIby a package maintainer. First, install the dependencies required for packaging and publishing:python-mpipinstall.[publish]Ensure that the correct version number appears inpyproject.toml, and that any links in this README document to the Read the Docs documentation of this package (or its dependencies) have appropriate version numbers. Also ensure that the Read the Docs project for this library has anautomation rulethat activates and sets as the default all tagged versions. Create and push a tag for this version (replacing?.?.?with the version number):gittag?.?.?gitpushorigin?.?.?Remove any old build/distribution files. Then, package the source into a distribution archive:rm-rfbuilddistsrc/*.egg-infopython-mbuild--sdist--wheel.Finally, upload the package distribution archive toPyPI:python-mtwineuploaddist/*