istr-python 1.1.40__tar.gz → 1.1.41__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.40
3
+ Version: 1.1.41
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
@@ -5,7 +5,7 @@
5
5
  # |_||___/ \__||_|
6
6
  # strings you can count on
7
7
 
8
- __version__ = "1.1.40"
8
+ __version__ = "1.1.41"
9
9
  import functools
10
10
  import itertools
11
11
  import types
@@ -767,6 +767,13 @@ class istr(str):
767
767
 
768
768
  return str(self)
769
769
 
770
+ def interpret_as_istr(self):
771
+ # ignore leading zeroes
772
+ if isinstance(self, collections.abc.Iterable) and not isinstance(self, str):
773
+ return istr.join(self)*1
774
+
775
+ return istr(self)*1
776
+
770
777
  def _str_method(self, name, *args, **kwargs):
771
778
  return self.__class__(getattr(super(), name)(*args, **kwargs))
772
779
 
@@ -864,7 +871,7 @@ class istr(str):
864
871
  if as_str is True, a formatted output will be returned
865
872
  """
866
873
 
867
- number = istr(istr.interpret_as_str(self))
874
+ number = istr.interpret_as_istr(self)
868
875
 
869
876
  lines = []
870
877
  if len(number)%2==1:
@@ -921,8 +928,8 @@ class istr(str):
921
928
  return lines
922
929
 
923
930
  def long_multiplication(self, number,as_str=False):
924
- number0 = istr(istr.interpret_as_str(self))
925
- number1=istr(number)
931
+ number0 = istr.interpret_as_istr(self)
932
+ number1=istr.interpret_as_istr(number)
926
933
  lines=[number0,number1]
927
934
  for i in number1.reversed():
928
935
  lines.append(number0*i)
@@ -942,8 +949,8 @@ class istr(str):
942
949
  return lines
943
950
 
944
951
  def long_division(self, divisor, as_str=False):
945
- dividend = istr(istr.interpret_as_str(self))
946
- divisor = istr(divisor)
952
+ dividend = istr.interpret_as_istr(self)
953
+ divisor = istr.interpret_as_istr(divisor)
947
954
 
948
955
  if dividend < 0:
949
956
  raise ValueError("dividend must be non-negative.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: istr-python
3
- Version: 1.1.40
3
+ Version: 1.1.41
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
@@ -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.40"
13
+ version = "1.1.41"
14
14
  readme = "README.md"
15
15
  requires-python = ">=3.10"
16
16
  dependencies = []
File without changes
File without changes