istr-python 1.1.36__tar.gz → 1.1.37__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {istr_python-1.1.36 → istr_python-1.1.37}/PKG-INFO +14 -4
- {istr_python-1.1.36 → istr_python-1.1.37}/README.md +13 -3
- {istr_python-1.1.36 → istr_python-1.1.37}/istr/istr.py +4 -1
- {istr_python-1.1.36 → istr_python-1.1.37}/istr_python.egg-info/PKG-INFO +14 -4
- {istr_python-1.1.36 → istr_python-1.1.37}/pyproject.toml +1 -1
- {istr_python-1.1.36 → istr_python-1.1.37}/tests/test_istr.py +6 -0
- {istr_python-1.1.36 → istr_python-1.1.37}/istr/LICENSE.txt +0 -0
- {istr_python-1.1.36 → istr_python-1.1.37}/istr/__init__.py +0 -0
- {istr_python-1.1.36 → istr_python-1.1.37}/istr/istr - Copy.py +0 -0
- {istr_python-1.1.36 → istr_python-1.1.37}/istr_python.egg-info/SOURCES.txt +0 -0
- {istr_python-1.1.36 → istr_python-1.1.37}/istr_python.egg-info/dependency_links.txt +0 -0
- {istr_python-1.1.36 → istr_python-1.1.37}/istr_python.egg-info/top_level.txt +0 -0
- {istr_python-1.1.36 → istr_python-1.1.37}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: istr-python
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.37
|
|
4
4
|
Summary: istr - strings you can count on
|
|
5
5
|
Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/salabim/istr
|
|
@@ -797,6 +797,16 @@ It is also possible to apply `prod` on an istr:
|
|
|
797
797
|
`istr(1234).prod()` is `istr(24)`
|
|
798
798
|
`istr("123").prod(start=4)` is `istr(24)`
|
|
799
799
|
|
|
800
|
+
#### sum to get sum of an iterable
|
|
801
|
+
|
|
802
|
+
The method `sum` can be used to return the sum of an iterable (including an istr), very much like the builtin sum function.
|
|
803
|
+
Thus, `istr.sum(range(1,5))` is `istr('10')`
|
|
804
|
+
And `istr.sum("123", start=4)` is also `istr('10')`.
|
|
805
|
+
|
|
806
|
+
It is also possible to apply `sum` on an istr:
|
|
807
|
+
`istr(1234).sum()` is `istr('10')`
|
|
808
|
+
`istr("123").prod(start=4)` is `istr('10')`
|
|
809
|
+
|
|
800
810
|
#### sumprod to get the sum of products of iterables
|
|
801
811
|
|
|
802
812
|
The class method `istr.sumprod()`, is equivalent to `math.sumprod()`, but applies istr to both iterables.
|
|
@@ -828,15 +838,15 @@ Note that the result will always be istr-ed, except when the result is None.
|
|
|
828
838
|
|
|
829
839
|
Examples:
|
|
830
840
|
```
|
|
831
|
-
istr(1234).getitem(2) ==>
|
|
841
|
+
istr(1234).getitem(2) ==> 3
|
|
832
842
|
istr(1234).getitem(-2) ==> 3
|
|
833
843
|
istr(1234).getitem(5) ==> istr('')
|
|
834
844
|
istr(1234).getitem(5, '0') ==> istr('0')
|
|
835
845
|
istr(1234).getitem(5, None) ==> None
|
|
836
846
|
```
|
|
837
|
-
This method can also be used with
|
|
847
|
+
This method can also be used with a str. E.g.:
|
|
838
848
|
```
|
|
839
|
-
istr.getitem('1234', 2) ==>
|
|
849
|
+
istr.getitem('1234', 2) ==> 3
|
|
840
850
|
istr.getitem('1234', -2) ==> 3
|
|
841
851
|
istr.getitem('1234', 5) ==> istr('')
|
|
842
852
|
istr.getitem('1234',5, '0') ==> istr('0')
|
|
@@ -784,6 +784,16 @@ It is also possible to apply `prod` on an istr:
|
|
|
784
784
|
`istr(1234).prod()` is `istr(24)`
|
|
785
785
|
`istr("123").prod(start=4)` is `istr(24)`
|
|
786
786
|
|
|
787
|
+
#### sum to get sum of an iterable
|
|
788
|
+
|
|
789
|
+
The method `sum` can be used to return the sum of an iterable (including an istr), very much like the builtin sum function.
|
|
790
|
+
Thus, `istr.sum(range(1,5))` is `istr('10')`
|
|
791
|
+
And `istr.sum("123", start=4)` is also `istr('10')`.
|
|
792
|
+
|
|
793
|
+
It is also possible to apply `sum` on an istr:
|
|
794
|
+
`istr(1234).sum()` is `istr('10')`
|
|
795
|
+
`istr("123").prod(start=4)` is `istr('10')`
|
|
796
|
+
|
|
787
797
|
#### sumprod to get the sum of products of iterables
|
|
788
798
|
|
|
789
799
|
The class method `istr.sumprod()`, is equivalent to `math.sumprod()`, but applies istr to both iterables.
|
|
@@ -815,15 +825,15 @@ Note that the result will always be istr-ed, except when the result is None.
|
|
|
815
825
|
|
|
816
826
|
Examples:
|
|
817
827
|
```
|
|
818
|
-
istr(1234).getitem(2) ==>
|
|
828
|
+
istr(1234).getitem(2) ==> 3
|
|
819
829
|
istr(1234).getitem(-2) ==> 3
|
|
820
830
|
istr(1234).getitem(5) ==> istr('')
|
|
821
831
|
istr(1234).getitem(5, '0') ==> istr('0')
|
|
822
832
|
istr(1234).getitem(5, None) ==> None
|
|
823
833
|
```
|
|
824
|
-
This method can also be used with
|
|
834
|
+
This method can also be used with a str. E.g.:
|
|
825
835
|
```
|
|
826
|
-
istr.getitem('1234', 2) ==>
|
|
836
|
+
istr.getitem('1234', 2) ==> 3
|
|
827
837
|
istr.getitem('1234', -2) ==> 3
|
|
828
838
|
istr.getitem('1234', 5) ==> istr('')
|
|
829
839
|
istr.getitem('1234',5, '0') ==> istr('0')
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# |_||___/ \__||_|
|
|
6
6
|
# strings you can count on
|
|
7
7
|
|
|
8
|
-
__version__ = "1.1.
|
|
8
|
+
__version__ = "1.1.37"
|
|
9
9
|
import functools
|
|
10
10
|
import itertools
|
|
11
11
|
import types
|
|
@@ -841,6 +841,9 @@ class istr(str):
|
|
|
841
841
|
|
|
842
842
|
def prod(self, *, start=1):
|
|
843
843
|
return math.prod(self, start=istr(start))
|
|
844
|
+
|
|
845
|
+
def sum(self, / , start=0):
|
|
846
|
+
return sum(istr(self), start=int(start))
|
|
844
847
|
|
|
845
848
|
@classmethod
|
|
846
849
|
def sumprod(cls, p, q, /, strict=True):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: istr-python
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.37
|
|
4
4
|
Summary: istr - strings you can count on
|
|
5
5
|
Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/salabim/istr
|
|
@@ -797,6 +797,16 @@ It is also possible to apply `prod` on an istr:
|
|
|
797
797
|
`istr(1234).prod()` is `istr(24)`
|
|
798
798
|
`istr("123").prod(start=4)` is `istr(24)`
|
|
799
799
|
|
|
800
|
+
#### sum to get sum of an iterable
|
|
801
|
+
|
|
802
|
+
The method `sum` can be used to return the sum of an iterable (including an istr), very much like the builtin sum function.
|
|
803
|
+
Thus, `istr.sum(range(1,5))` is `istr('10')`
|
|
804
|
+
And `istr.sum("123", start=4)` is also `istr('10')`.
|
|
805
|
+
|
|
806
|
+
It is also possible to apply `sum` on an istr:
|
|
807
|
+
`istr(1234).sum()` is `istr('10')`
|
|
808
|
+
`istr("123").prod(start=4)` is `istr('10')`
|
|
809
|
+
|
|
800
810
|
#### sumprod to get the sum of products of iterables
|
|
801
811
|
|
|
802
812
|
The class method `istr.sumprod()`, is equivalent to `math.sumprod()`, but applies istr to both iterables.
|
|
@@ -828,15 +838,15 @@ Note that the result will always be istr-ed, except when the result is None.
|
|
|
828
838
|
|
|
829
839
|
Examples:
|
|
830
840
|
```
|
|
831
|
-
istr(1234).getitem(2) ==>
|
|
841
|
+
istr(1234).getitem(2) ==> 3
|
|
832
842
|
istr(1234).getitem(-2) ==> 3
|
|
833
843
|
istr(1234).getitem(5) ==> istr('')
|
|
834
844
|
istr(1234).getitem(5, '0') ==> istr('0')
|
|
835
845
|
istr(1234).getitem(5, None) ==> None
|
|
836
846
|
```
|
|
837
|
-
This method can also be used with
|
|
847
|
+
This method can also be used with a str. E.g.:
|
|
838
848
|
```
|
|
839
|
-
istr.getitem('1234', 2) ==>
|
|
849
|
+
istr.getitem('1234', 2) ==> 3
|
|
840
850
|
istr.getitem('1234', -2) ==> 3
|
|
841
851
|
istr.getitem('1234', 5) ==> istr('')
|
|
842
852
|
istr.getitem('1234',5, '0') ==> istr('0')
|
|
@@ -1066,6 +1066,12 @@ def test_is_triangular():
|
|
|
1066
1066
|
assert istr(424581).is_triangular()
|
|
1067
1067
|
assert not istr(424582).is_triangular()
|
|
1068
1068
|
assert istr.is_triangular(424581)
|
|
1069
|
+
|
|
1070
|
+
def test_sum():
|
|
1071
|
+
assert istr(1234).sum() == istr('10')
|
|
1072
|
+
assert istr.sum('1234') == istr('10')
|
|
1073
|
+
assert istr.sum(1234) == istr('10')
|
|
1074
|
+
assert istr.sum(1234, 5) == istr('15')
|
|
1069
1075
|
|
|
1070
1076
|
|
|
1071
1077
|
def test_prod():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|