istr-python 1.1.28__tar.gz → 1.1.29__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.28
3
+ Version: 1.1.29
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
@@ -335,7 +335,7 @@ several other types:
335
335
  ```
336
336
  istr([0, 1, 4]) ==> [istr('0'), istr('1'), istr('4')]
337
337
  istr((0, 1, 4)) ==> (istr('0'), istr('1'), istr('4'))
338
- istr({0, 1, 4}) ==> `{istr('4'), istr('0'), istr('1')} # or similar
338
+ istr({0, 1, 4}) ==> {istr('4'), istr('0'), istr('1')} # or similar
339
339
  ```
340
340
 
341
341
  - if a range, an istr.range instance will be returned
@@ -430,7 +430,7 @@ unless the *fallback* (last argument) is given, in which case *fallback* will be
430
430
  istr(18).divided_by(3) ==> 6 (actually istr("6"))
431
431
  istr(18).divided_by(istr(3)) ==> 6
432
432
  istr(19).divided_by(3) ==> None
433
- istr(19).divided_by(3, 0) ==>
433
+ istr(19).divided_by(3, 0) ==> 0
434
434
  istr(19).divided_by(3) ==> None
435
435
  istr(19).divided_by(istr(3)) ==> None
436
436
  istr.divided_by(18, 3) ==> 6
@@ -461,7 +461,7 @@ istr(28).is_cube()) ==> False
461
461
  It is also possible to test for cube of an ordinary int:
462
462
  ```
463
463
  istr.is_cube(27) ==> True
464
- istr.is_cube(28 ==> False
464
+ istr.is_cube(28) ==> False
465
465
  ```
466
466
 
467
467
  #### test for power of
@@ -544,6 +544,7 @@ istr('0456')[::-1] ==> istr('6540')
544
544
  > It is possible to reverse a negative istr, but the result can't be interpreted as an int anymore.
545
545
  >
546
546
  > ```
547
+ > istr(-456).reversed() ==> istr('654-')
547
548
  > istr(-456).reversed() + 3 ==> TypeError
548
549
  > ```
549
550
 
@@ -737,7 +738,7 @@ To decompose an istr into individual variables, it is arguably easier and safer
737
738
  a, b, c = istr(485)
738
739
  ```
739
740
 
740
- With `istr.compose()`, an istr can be constructed from individual (global) variables and digits.
741
+ With `istr.compose()`, an istr can be constructed from individual (global) variables and letters that can't be identifiers.
741
742
  E.g.
742
743
 
743
744
  ```
@@ -746,17 +747,19 @@ y = 9
746
747
  z = 6
747
748
  test1 = istr.compose("xyz")
748
749
  test2 = istr.compose("xyz0")
750
+ test3 = istr.compose("(xyz)")
749
751
  ```
750
- Now, `test1` will be `istr(396)` and `test2` will be `istr(3960)`.
752
+ Now, `test1` will be `istr(396)`, `test2` will be `istr(3960)` and `test3` will be `istr("(396)")`.
751
753
 
752
- Composing can also be done by prefixing a string with '=', like:
754
+ Composing can also be done by prefixing a string with `=`, like:
753
755
 
754
756
  ```
755
757
  test1 = istr("=xyz")
756
758
  test2 = istr("=xyz0")
757
-
758
- Now, `test1` will be `istr(396)` and `test2` will be `istr(3960)`.
759
+ test3 = istr("=(xyz)")
759
760
  ```
761
+ Now, `test1` will be `istr(396)`, `test2` will be `istr(3960)` and `test3` will be `istr("(396)")`.
762
+
760
763
  Note that `str(istr("="))` is "=".
761
764
 
762
765
  Composing and assignment can be done by prefixing a string with ':=', like:
@@ -947,31 +950,32 @@ operator/function int str Example
947
950
  + x istr(20) + 3 ==> istr('23')
948
951
  _ x istr(20) - 3 ==> istr('17')
949
952
  * x istr(20) * 3 ==> istr('60')
950
- / x istr(20) / 3 ==> istr('6')
951
- // x istr(20) // 3 ==> istr('6')
952
- % x istr(20) % 3 ==> istr('2')
953
- divmod x divmod(istr(20), 3) ==> (istr('6'), istr('2'))
954
- ** x istr(2) ** 3 ==> istr('8')
955
- <=, <, >, >= x istr('100') > istr('2') ==> True
956
- abs x abs(istr(-20)) ==> istr('20')
957
- int x int(istr("20")) ==> 20
958
- float x float(istr("20")) ==> 20.0
959
- complex x complex(istr("20")) ==> (20+0j)
960
- == x x istr(20) == 20 ==> True | istr(20) == '20' ==> True
961
- bool x x *) bool(istr(' 0 ')) ==> False | bool(istr('')) ==> False
962
- @ x istr(20) @ 3 ==> istr('202020')
963
- | x istr(20) | '5' ==> istr('205')
964
- slicing x istr(12345)[1:3] ==> istr('23')
965
- iterate x [x for x in istr(20)] ==> [istr('2'), istr('0')]
966
- len x len(istr(' 20 ')) ==> 4
967
- count x istr(100).count(0) ==> 2
968
- index x istr(' 100 ').index('0') ==> 2
969
- split x istr('1 2').split() ==> (istr('1'), istr('2'))
970
- string format x f"|{istr(1234):6}|" ==> '|1234 |'
971
- other string methods x istr('aAbBcC').lower() ==> istr('aabbcc')
972
- istr('aAbBcC').islower() ==> False
973
- istr(' abc ').strip() ==> istr('abc')
974
- ...
953
+ / x istr(20) / 3 ==> istr('6')
954
+ // x istr(20) // 3 ==> istr('6')
955
+ % x istr(20) % 3 ==> istr('2')
956
+ divmod x divmod(istr(20), 3) ==> (istr('6'), istr('2'))
957
+ ** x istr(2) ** 3 ==> istr('8')
958
+ <=, <, >, >= x istr('100') > istr('2') ==> True
959
+ abs x abs(istr(-20)) ==> istr('20')
960
+ int x int(istr("20")) ==> 20
961
+ float x float(istr("20")) ==> 20.0
962
+ complex x complex(istr("20")) ==> (20+0j)
963
+ == x x istr(20) == 20 ==> True | istr(20) == '20' ==> True
964
+ bool x x *) bool(istr(' 0 ')) ==> False | bool(istr('')) ==> False
965
+ @ x istr(20) @ 3 ==> istr('202020')
966
+ | x istr(20) | '5' ==> istr('205')
967
+ slicing x istr(12345)[1:3] ==> istr('23')
968
+ iterate x [x for x in istr(20)] ==> [istr('2'), istr('0')]
969
+ len x len(istr(' 20 ')) ==> 4
970
+ count x istr(100).count(0) ==> 2
971
+ istr.count(100) ==> istr('100'), istr('101'). istr('102'), ...
972
+ index x istr(' 100 ').index('0') ==> 2
973
+ split x istr('1 2').split() ==> (istr('1'), istr('2'))
974
+ string format x f"|{istr(1234):6}|" ==> '|1234 |'
975
+ other string methods x istr('aAbBcC').lower() ==> istr('aabbcc')
976
+ istr('aAbBcC').islower() ==> False
977
+ istr(' abc ').strip() ==> istr('abc')
978
+ ...
975
979
  -----------------------------------------------------------------------------------------
976
980
  *) str is applied if is_int() is False
977
981
  ```
@@ -322,7 +322,7 @@ several other types:
322
322
  ```
323
323
  istr([0, 1, 4]) ==> [istr('0'), istr('1'), istr('4')]
324
324
  istr((0, 1, 4)) ==> (istr('0'), istr('1'), istr('4'))
325
- istr({0, 1, 4}) ==> `{istr('4'), istr('0'), istr('1')} # or similar
325
+ istr({0, 1, 4}) ==> {istr('4'), istr('0'), istr('1')} # or similar
326
326
  ```
327
327
 
328
328
  - if a range, an istr.range instance will be returned
@@ -417,7 +417,7 @@ unless the *fallback* (last argument) is given, in which case *fallback* will be
417
417
  istr(18).divided_by(3) ==> 6 (actually istr("6"))
418
418
  istr(18).divided_by(istr(3)) ==> 6
419
419
  istr(19).divided_by(3) ==> None
420
- istr(19).divided_by(3, 0) ==>
420
+ istr(19).divided_by(3, 0) ==> 0
421
421
  istr(19).divided_by(3) ==> None
422
422
  istr(19).divided_by(istr(3)) ==> None
423
423
  istr.divided_by(18, 3) ==> 6
@@ -448,7 +448,7 @@ istr(28).is_cube()) ==> False
448
448
  It is also possible to test for cube of an ordinary int:
449
449
  ```
450
450
  istr.is_cube(27) ==> True
451
- istr.is_cube(28 ==> False
451
+ istr.is_cube(28) ==> False
452
452
  ```
453
453
 
454
454
  #### test for power of
@@ -531,6 +531,7 @@ istr('0456')[::-1] ==> istr('6540')
531
531
  > It is possible to reverse a negative istr, but the result can't be interpreted as an int anymore.
532
532
  >
533
533
  > ```
534
+ > istr(-456).reversed() ==> istr('654-')
534
535
  > istr(-456).reversed() + 3 ==> TypeError
535
536
  > ```
536
537
 
@@ -724,7 +725,7 @@ To decompose an istr into individual variables, it is arguably easier and safer
724
725
  a, b, c = istr(485)
725
726
  ```
726
727
 
727
- With `istr.compose()`, an istr can be constructed from individual (global) variables and digits.
728
+ With `istr.compose()`, an istr can be constructed from individual (global) variables and letters that can't be identifiers.
728
729
  E.g.
729
730
 
730
731
  ```
@@ -733,17 +734,19 @@ y = 9
733
734
  z = 6
734
735
  test1 = istr.compose("xyz")
735
736
  test2 = istr.compose("xyz0")
737
+ test3 = istr.compose("(xyz)")
736
738
  ```
737
- Now, `test1` will be `istr(396)` and `test2` will be `istr(3960)`.
739
+ Now, `test1` will be `istr(396)`, `test2` will be `istr(3960)` and `test3` will be `istr("(396)")`.
738
740
 
739
- Composing can also be done by prefixing a string with '=', like:
741
+ Composing can also be done by prefixing a string with `=`, like:
740
742
 
741
743
  ```
742
744
  test1 = istr("=xyz")
743
745
  test2 = istr("=xyz0")
744
-
745
- Now, `test1` will be `istr(396)` and `test2` will be `istr(3960)`.
746
+ test3 = istr("=(xyz)")
746
747
  ```
748
+ Now, `test1` will be `istr(396)`, `test2` will be `istr(3960)` and `test3` will be `istr("(396)")`.
749
+
747
750
  Note that `str(istr("="))` is "=".
748
751
 
749
752
  Composing and assignment can be done by prefixing a string with ':=', like:
@@ -934,31 +937,32 @@ operator/function int str Example
934
937
  + x istr(20) + 3 ==> istr('23')
935
938
  _ x istr(20) - 3 ==> istr('17')
936
939
  * x istr(20) * 3 ==> istr('60')
937
- / x istr(20) / 3 ==> istr('6')
938
- // x istr(20) // 3 ==> istr('6')
939
- % x istr(20) % 3 ==> istr('2')
940
- divmod x divmod(istr(20), 3) ==> (istr('6'), istr('2'))
941
- ** x istr(2) ** 3 ==> istr('8')
942
- <=, <, >, >= x istr('100') > istr('2') ==> True
943
- abs x abs(istr(-20)) ==> istr('20')
944
- int x int(istr("20")) ==> 20
945
- float x float(istr("20")) ==> 20.0
946
- complex x complex(istr("20")) ==> (20+0j)
947
- == x x istr(20) == 20 ==> True | istr(20) == '20' ==> True
948
- bool x x *) bool(istr(' 0 ')) ==> False | bool(istr('')) ==> False
949
- @ x istr(20) @ 3 ==> istr('202020')
950
- | x istr(20) | '5' ==> istr('205')
951
- slicing x istr(12345)[1:3] ==> istr('23')
952
- iterate x [x for x in istr(20)] ==> [istr('2'), istr('0')]
953
- len x len(istr(' 20 ')) ==> 4
954
- count x istr(100).count(0) ==> 2
955
- index x istr(' 100 ').index('0') ==> 2
956
- split x istr('1 2').split() ==> (istr('1'), istr('2'))
957
- string format x f"|{istr(1234):6}|" ==> '|1234 |'
958
- other string methods x istr('aAbBcC').lower() ==> istr('aabbcc')
959
- istr('aAbBcC').islower() ==> False
960
- istr(' abc ').strip() ==> istr('abc')
961
- ...
940
+ / x istr(20) / 3 ==> istr('6')
941
+ // x istr(20) // 3 ==> istr('6')
942
+ % x istr(20) % 3 ==> istr('2')
943
+ divmod x divmod(istr(20), 3) ==> (istr('6'), istr('2'))
944
+ ** x istr(2) ** 3 ==> istr('8')
945
+ <=, <, >, >= x istr('100') > istr('2') ==> True
946
+ abs x abs(istr(-20)) ==> istr('20')
947
+ int x int(istr("20")) ==> 20
948
+ float x float(istr("20")) ==> 20.0
949
+ complex x complex(istr("20")) ==> (20+0j)
950
+ == x x istr(20) == 20 ==> True | istr(20) == '20' ==> True
951
+ bool x x *) bool(istr(' 0 ')) ==> False | bool(istr('')) ==> False
952
+ @ x istr(20) @ 3 ==> istr('202020')
953
+ | x istr(20) | '5' ==> istr('205')
954
+ slicing x istr(12345)[1:3] ==> istr('23')
955
+ iterate x [x for x in istr(20)] ==> [istr('2'), istr('0')]
956
+ len x len(istr(' 20 ')) ==> 4
957
+ count x istr(100).count(0) ==> 2
958
+ istr.count(100) ==> istr('100'), istr('101'). istr('102'), ...
959
+ index x istr(' 100 ').index('0') ==> 2
960
+ split x istr('1 2').split() ==> (istr('1'), istr('2'))
961
+ string format x f"|{istr(1234):6}|" ==> '|1234 |'
962
+ other string methods x istr('aAbBcC').lower() ==> istr('aabbcc')
963
+ istr('aAbBcC').islower() ==> False
964
+ istr(' abc ').strip() ==> istr('abc')
965
+ ...
962
966
  -----------------------------------------------------------------------------------------
963
967
  *) str is applied if is_int() is False
964
968
  ```
@@ -5,7 +5,7 @@
5
5
  # |_||___/ \__||_|
6
6
  # strings you can count on
7
7
 
8
- __version__ = "1.1.28"
8
+ __version__ = "1.1.29"
9
9
  import functools
10
10
  import itertools
11
11
  import types
@@ -600,14 +600,16 @@ class istr(str):
600
600
  namespace = get_namespace(namespace)
601
601
 
602
602
  lookup = {}
603
+
604
+ if len(letters) != len(self):
605
+ raise ValueError(f"incorrect number of variables {len(letters)}; should be {len(self)}")
606
+
603
607
  for letter, ch in zip(letters, self):
604
608
  if letter in lookup and lookup[letter] != ch:
605
609
  raise ValueError(f"multiple values found for variable {letter}")
606
610
  if not letter.isidentifier():
607
611
  raise ValueError(f"{repr(letter)} cannot be used as a variable")
608
612
  lookup[str(letter)] = ch
609
- if len(letters) != len(self):
610
- raise ValueError(f"incorrect number of variables {len(letters)}; should be {len(self)}")
611
613
  namespace.update(lookup)
612
614
 
613
615
  @classmethod
@@ -615,13 +617,16 @@ class istr(str):
615
617
  """
616
618
  compose an istr from individual letter variables
617
619
  """
618
- namespace = get_namespace(namespace) | {ch: ch for ch in "0123456789_"}
620
+ namespace = get_namespace(namespace)
621
+ result=[]
619
622
  for letter in letters:
620
623
  if letter.isidentifier():
621
624
  if letter not in namespace:
622
625
  raise ValueError(f"variable {repr(letter)} not defined")
623
- s = "".join(str(namespace[letter]) for letter in letters)
624
- return cls(s)
626
+ result.append(str(namespace[letter]))
627
+ else:
628
+ result.append(letter)
629
+ return cls("".join(result))
625
630
 
626
631
  def __or__(self, other):
627
632
  if isinstance(other, str):
@@ -762,7 +767,8 @@ class istr(str):
762
767
 
763
768
  cls._int_format = int_format
764
769
 
765
- def __enter__(self): ...
770
+ def __enter__(self):
771
+ ...
766
772
 
767
773
  def __exit__(self, exc_type, exc_value, exc_tb):
768
774
  self.saved_cls._int_format = self.saved_int_format
@@ -783,7 +789,8 @@ class istr(str):
783
789
  self.saved_cls = cls
784
790
  cls._repr_mode = mode
785
791
 
786
- def __enter__(self): ...
792
+ def __enter__(self):
793
+ ...
787
794
 
788
795
  def __exit__(self, exc_type, exc_value, exc_tb):
789
796
  self.saved_cls._repr_mode = self.saved_repr_mode
@@ -802,7 +809,8 @@ class istr(str):
802
809
  self.saved_cls = cls
803
810
  cls._base = base
804
811
 
805
- def __enter__(self): ...
812
+ def __enter__(self):
813
+ ...
806
814
 
807
815
  def __exit__(self, exc_type, exc_value, exc_tb):
808
816
  self.saved_cls._base = self.saved_base
@@ -984,3 +992,4 @@ class istrModule(types.ModuleType):
984
992
 
985
993
  if __name__ != "__main__":
986
994
  sys.modules["istr"].__class__ = istrModule
995
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: istr-python
3
- Version: 1.1.28
3
+ Version: 1.1.29
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
@@ -335,7 +335,7 @@ several other types:
335
335
  ```
336
336
  istr([0, 1, 4]) ==> [istr('0'), istr('1'), istr('4')]
337
337
  istr((0, 1, 4)) ==> (istr('0'), istr('1'), istr('4'))
338
- istr({0, 1, 4}) ==> `{istr('4'), istr('0'), istr('1')} # or similar
338
+ istr({0, 1, 4}) ==> {istr('4'), istr('0'), istr('1')} # or similar
339
339
  ```
340
340
 
341
341
  - if a range, an istr.range instance will be returned
@@ -430,7 +430,7 @@ unless the *fallback* (last argument) is given, in which case *fallback* will be
430
430
  istr(18).divided_by(3) ==> 6 (actually istr("6"))
431
431
  istr(18).divided_by(istr(3)) ==> 6
432
432
  istr(19).divided_by(3) ==> None
433
- istr(19).divided_by(3, 0) ==>
433
+ istr(19).divided_by(3, 0) ==> 0
434
434
  istr(19).divided_by(3) ==> None
435
435
  istr(19).divided_by(istr(3)) ==> None
436
436
  istr.divided_by(18, 3) ==> 6
@@ -461,7 +461,7 @@ istr(28).is_cube()) ==> False
461
461
  It is also possible to test for cube of an ordinary int:
462
462
  ```
463
463
  istr.is_cube(27) ==> True
464
- istr.is_cube(28 ==> False
464
+ istr.is_cube(28) ==> False
465
465
  ```
466
466
 
467
467
  #### test for power of
@@ -544,6 +544,7 @@ istr('0456')[::-1] ==> istr('6540')
544
544
  > It is possible to reverse a negative istr, but the result can't be interpreted as an int anymore.
545
545
  >
546
546
  > ```
547
+ > istr(-456).reversed() ==> istr('654-')
547
548
  > istr(-456).reversed() + 3 ==> TypeError
548
549
  > ```
549
550
 
@@ -737,7 +738,7 @@ To decompose an istr into individual variables, it is arguably easier and safer
737
738
  a, b, c = istr(485)
738
739
  ```
739
740
 
740
- With `istr.compose()`, an istr can be constructed from individual (global) variables and digits.
741
+ With `istr.compose()`, an istr can be constructed from individual (global) variables and letters that can't be identifiers.
741
742
  E.g.
742
743
 
743
744
  ```
@@ -746,17 +747,19 @@ y = 9
746
747
  z = 6
747
748
  test1 = istr.compose("xyz")
748
749
  test2 = istr.compose("xyz0")
750
+ test3 = istr.compose("(xyz)")
749
751
  ```
750
- Now, `test1` will be `istr(396)` and `test2` will be `istr(3960)`.
752
+ Now, `test1` will be `istr(396)`, `test2` will be `istr(3960)` and `test3` will be `istr("(396)")`.
751
753
 
752
- Composing can also be done by prefixing a string with '=', like:
754
+ Composing can also be done by prefixing a string with `=`, like:
753
755
 
754
756
  ```
755
757
  test1 = istr("=xyz")
756
758
  test2 = istr("=xyz0")
757
-
758
- Now, `test1` will be `istr(396)` and `test2` will be `istr(3960)`.
759
+ test3 = istr("=(xyz)")
759
760
  ```
761
+ Now, `test1` will be `istr(396)`, `test2` will be `istr(3960)` and `test3` will be `istr("(396)")`.
762
+
760
763
  Note that `str(istr("="))` is "=".
761
764
 
762
765
  Composing and assignment can be done by prefixing a string with ':=', like:
@@ -947,31 +950,32 @@ operator/function int str Example
947
950
  + x istr(20) + 3 ==> istr('23')
948
951
  _ x istr(20) - 3 ==> istr('17')
949
952
  * x istr(20) * 3 ==> istr('60')
950
- / x istr(20) / 3 ==> istr('6')
951
- // x istr(20) // 3 ==> istr('6')
952
- % x istr(20) % 3 ==> istr('2')
953
- divmod x divmod(istr(20), 3) ==> (istr('6'), istr('2'))
954
- ** x istr(2) ** 3 ==> istr('8')
955
- <=, <, >, >= x istr('100') > istr('2') ==> True
956
- abs x abs(istr(-20)) ==> istr('20')
957
- int x int(istr("20")) ==> 20
958
- float x float(istr("20")) ==> 20.0
959
- complex x complex(istr("20")) ==> (20+0j)
960
- == x x istr(20) == 20 ==> True | istr(20) == '20' ==> True
961
- bool x x *) bool(istr(' 0 ')) ==> False | bool(istr('')) ==> False
962
- @ x istr(20) @ 3 ==> istr('202020')
963
- | x istr(20) | '5' ==> istr('205')
964
- slicing x istr(12345)[1:3] ==> istr('23')
965
- iterate x [x for x in istr(20)] ==> [istr('2'), istr('0')]
966
- len x len(istr(' 20 ')) ==> 4
967
- count x istr(100).count(0) ==> 2
968
- index x istr(' 100 ').index('0') ==> 2
969
- split x istr('1 2').split() ==> (istr('1'), istr('2'))
970
- string format x f"|{istr(1234):6}|" ==> '|1234 |'
971
- other string methods x istr('aAbBcC').lower() ==> istr('aabbcc')
972
- istr('aAbBcC').islower() ==> False
973
- istr(' abc ').strip() ==> istr('abc')
974
- ...
953
+ / x istr(20) / 3 ==> istr('6')
954
+ // x istr(20) // 3 ==> istr('6')
955
+ % x istr(20) % 3 ==> istr('2')
956
+ divmod x divmod(istr(20), 3) ==> (istr('6'), istr('2'))
957
+ ** x istr(2) ** 3 ==> istr('8')
958
+ <=, <, >, >= x istr('100') > istr('2') ==> True
959
+ abs x abs(istr(-20)) ==> istr('20')
960
+ int x int(istr("20")) ==> 20
961
+ float x float(istr("20")) ==> 20.0
962
+ complex x complex(istr("20")) ==> (20+0j)
963
+ == x x istr(20) == 20 ==> True | istr(20) == '20' ==> True
964
+ bool x x *) bool(istr(' 0 ')) ==> False | bool(istr('')) ==> False
965
+ @ x istr(20) @ 3 ==> istr('202020')
966
+ | x istr(20) | '5' ==> istr('205')
967
+ slicing x istr(12345)[1:3] ==> istr('23')
968
+ iterate x [x for x in istr(20)] ==> [istr('2'), istr('0')]
969
+ len x len(istr(' 20 ')) ==> 4
970
+ count x istr(100).count(0) ==> 2
971
+ istr.count(100) ==> istr('100'), istr('101'). istr('102'), ...
972
+ index x istr(' 100 ').index('0') ==> 2
973
+ split x istr('1 2').split() ==> (istr('1'), istr('2'))
974
+ string format x f"|{istr(1234):6}|" ==> '|1234 |'
975
+ other string methods x istr('aAbBcC').lower() ==> istr('aabbcc')
976
+ istr('aAbBcC').islower() ==> False
977
+ istr(' abc ').strip() ==> istr('abc')
978
+ ...
975
979
  -----------------------------------------------------------------------------------------
976
980
  *) str is applied if is_int() is False
977
981
  ```
@@ -10,7 +10,7 @@ authors = [
10
10
  { name = "Ruud van der Ham", email = "rt.van.der.ham@gmail.com" },
11
11
  ]
12
12
  description = "istr - strings you can count on"
13
- version = "1.1.28"
13
+ version = "1.1.29"
14
14
  readme = "README.md"
15
15
  requires-python = ">=3.10"
16
16
  dependencies = []
@@ -989,11 +989,10 @@ def test_decompose():
989
989
 
990
990
 
991
991
  def test_compose():
992
+ global x, y, z, _
992
993
  x = 1
993
994
  y = "2"
994
995
  z = istr(3)
995
-
996
- assert istr.compose("xyz").equals(istr(123))
997
996
  with pytest.raises(ValueError):
998
997
  istr.compose("wxyz") # w is not defined
999
998
  assert istr.compose("xyz", namespace=dict(x=3, y=istr(4), z="5")).equals(istr(345))
@@ -1015,7 +1014,10 @@ def test_compose():
1015
1014
  assert istr(":=xyz").equals(istr(123))
1016
1015
  assert xyz.equals(istr(123))
1017
1016
 
1018
- assert istr(":=xyz_000").equals(istr("123_000"))
1017
+ with pytest.raises(ValueError):
1018
+ istr("=123_000")
1019
+ _ = "_"
1020
+ xyz_000 = istr("=123_000")
1019
1021
  assert xyz_000.equals(istr("123_000"))
1020
1022
  assert xyz_000 == 123000
1021
1023
 
File without changes