istr-python 1.1.31__tar.gz → 1.1.32.post0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: istr-python
3
- Version: 1.1.31
3
+ Version: 1.1.32.post0
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
@@ -526,6 +526,19 @@ istr(7).is_triangular() ==> False
526
526
 
527
527
  Note that this method can also be used for non-istr-s, like `istr.is_triangular(6) ==> True`.
528
528
 
529
+ #### calling test methods with an iterable
530
+
531
+ The test functions`istr.is_odd`, `istr.is_even`, `istr.is_divisible_by`, `istr.is_square`, `istr.is_cube`, `istr.is_power_of`, `istr.is_triangular`, `istr.is_palindrome`, ``istr.is_consecutive`, `istr.is_increasing`, `istr.is_non_decreasing`, `istr.is_decreasing` and `istr.is_non_increasing` also accepts an iterable, which is joined prior to the test.
532
+ This is particularly useful to filter tuples yielded from permutations, combinations, combinations_with_replacement and product.
533
+ So, we can do
534
+
535
+ ```
536
+ map(istr.join,filter(istr.prime, istr.combinations(range(10),2)))
537
+ ==> istr('02'), istr('03'), ... istr('89')
538
+ ```
539
+
540
+ #### version 1.1.30 2026-05-19
541
+
529
542
 
530
543
  #### reverse an istr
531
544
 
@@ -641,7 +654,7 @@ The following class methods are supported (provided their counterpart exists in
641
654
 
642
655
  This can be handy as these methods don't have to be imported from itertools anymore.
643
656
 
644
- All methods have exactly the same (optional) parameters as their itertools counterpart.
657
+ All methods have exactly the same (optional) parameters as their itertools counterpart, apart from `istr.permutations`, `istr.combinations`, `istr.combinations_with_replacement`, `istr.product`, `istr.batched`, `istr.pairwise` and `istr.zip_longest` which have an extra optional keyword parameter join (see below).
645
658
 
646
659
  For example:
647
660
 
@@ -666,6 +679,23 @@ results in
666
679
  (istr('2'), istr('1'), istr('0'))
667
680
  ```
668
681
 
682
+ The methods `istr.permutations`, `istr.combinations`, `istr.combinations_with_replacement`, `istr.product`, `istr.batched`, `istr.pairwise` and `istr.zip_longest` have an extra optional keyword parameter join, that is False by default.
683
+ If False, the methods just produce an iterable returning tuples. If True, the tuples are joined to make an istr. So,
684
+
685
+ ```
686
+ for t in istr.permutations(range(3), join=True):
687
+ print(repr(t))
688
+ ```
689
+ results in
690
+ ```
691
+ istr('012')
692
+ istr('021')
693
+ istr('102')
694
+ istr('120')
695
+ istr('201')
696
+ istr('210')
697
+ ```
698
+
669
699
  Note that the count method is also used like `istr(100).find(0)` , using the count method of strings. The context defines which version is used:
670
700
 
671
701
  ```
@@ -678,6 +708,20 @@ istr.count(10) ==> istr('10'), istr('11'), istr('12'), ...
678
708
  istr.count(10,3) ==> istr('10'), istr('13'), istr('16'), ...
679
709
  ```
680
710
 
711
+ #### istr.zip
712
+
713
+ The class method `istr.zip` is the equivalent of the zip builtin, but applies istr to each element. `istr.zip` also supports the join parameter:
714
+ ```
715
+ print(list(istr.zip('12', '345')))
716
+ print(list(istr.zip('12', '345', join=True)))
717
+ print(list(istr.zip('12', '345', strict=True)))
718
+ ```
719
+ results in
720
+ ```
721
+ [(istr('1'), istr('3')), (istr('2'), istr('4'))]
722
+ [istr('13'), istr('24')]
723
+ ValueError: zip() argument 2 is longer than argument 1
724
+ ```
681
725
  #### concatenate an iterable
682
726
 
683
727
  The `istr.concat` method can be useful to map all items of an iterable
@@ -695,7 +739,7 @@ list(istr.concat(istr.permutations(range(3),2))) ==>
695
739
 
696
740
  The method `prod` can be used to return the product of an iterable (including an istr), like `math.prod`, but as istr.
697
741
  Thus, `istr.prod(range(1,5))` is `istr(24)`
698
- And `istr("123", start=4)` is also `istr(24)`.
742
+ And `istr.prod("123", start=4)` is also `istr(24)`.
699
743
 
700
744
  It is also possible to apply `prod` on an istr:
701
745
  `istr(1234).prod()` is `istr(24)`