istr-python 1.1.4__tar.gz → 1.1.5__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.4/istr_python.egg-info → istr_python-1.1.5}/PKG-INFO +50 -2
- istr_python-1.1.4/PKG-INFO → istr_python-1.1.5/README.md +812 -777
- {istr_python-1.1.4 → istr_python-1.1.5}/istr/istr.py +30 -25
- istr_python-1.1.4/README.md → istr_python-1.1.5/istr_python.egg-info/PKG-INFO +825 -764
- {istr_python-1.1.4 → istr_python-1.1.5}/pyproject.toml +1 -1
- {istr_python-1.1.4 → istr_python-1.1.5}/tests/test_istr.py +37 -1
- {istr_python-1.1.4 → istr_python-1.1.5}/istr/LICENSE.txt +0 -0
- {istr_python-1.1.4 → istr_python-1.1.5}/istr/__init__.py +0 -0
- {istr_python-1.1.4 → istr_python-1.1.5}/istr_python.egg-info/SOURCES.txt +0 -0
- {istr_python-1.1.4 → istr_python-1.1.5}/istr_python.egg-info/dependency_links.txt +0 -0
- {istr_python-1.1.4 → istr_python-1.1.5}/istr_python.egg-info/top_level.txt +0 -0
- {istr_python-1.1.4 → istr_python-1.1.5}/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.5
|
|
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
|
|
@@ -362,7 +362,7 @@ istr.is_odd(5) ==> True
|
|
|
362
362
|
```
|
|
363
363
|
#### test for square
|
|
364
364
|
|
|
365
|
-
It is possible to test whether the value is a perfect
|
|
365
|
+
It is possible to test whether the value is a perfect square (provided the istr can be interpreted as an int) with the `is_square` method, e.g.
|
|
366
366
|
|
|
367
367
|
```
|
|
368
368
|
istr(4).is_square() ==> True
|
|
@@ -372,7 +372,33 @@ It is also possible to test for square of an ordinary int:
|
|
|
372
372
|
```
|
|
373
373
|
istr.is_square(4) ==> True
|
|
374
374
|
istr.is_square(5) ==> False
|
|
375
|
+
|
|
376
|
+
#### test for cube
|
|
377
|
+
|
|
378
|
+
It is possible to test whether the value is a perfect cube (provided the istr can be interpreted as an int) with the `is_cube` method, e.g.
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
istr(27).is_cube() ==> True
|
|
382
|
+
istr(28).is_cube()) ==> False
|
|
383
|
+
```
|
|
384
|
+
It is also possible to test for cube of an ordinary int:
|
|
385
|
+
```
|
|
386
|
+
istr.is_cube(27) ==> True
|
|
387
|
+
istr.is_cube(28 ==> False
|
|
388
|
+
|
|
389
|
+
#### test for power of
|
|
390
|
+
|
|
391
|
+
It is possible to test whether the value is a perfect power of a given exponent (provided the istr can be interpreted as an int) with the `is_power_of` method, e.g.
|
|
392
|
+
|
|
375
393
|
```
|
|
394
|
+
istr(81).is_power_of(4) ==> True
|
|
395
|
+
istr(82).is_power_of(4) ==> False
|
|
396
|
+
```
|
|
397
|
+
It is also possible to test for power of of an ordinary int:
|
|
398
|
+
```
|
|
399
|
+
istr.is_power_of(81, 4) ==> True
|
|
400
|
+
istr.is_power_of(82, 4) ==> False
|
|
401
|
+
|
|
376
402
|
#### test for prime
|
|
377
403
|
|
|
378
404
|
It is possible to test whether the value is a prime number (provided the istr can be interpreted as an int) with the `is_prime` method, e.g.
|
|
@@ -558,8 +584,30 @@ istr.digits('3-') ==> istr('34567879')
|
|
|
558
584
|
istr.digits('X-') ==> istr('XYZ')
|
|
559
585
|
```
|
|
560
586
|
|
|
587
|
+
#### Decomposing to and composing from letter variables
|
|
588
|
+
|
|
589
|
+
When we have an istr, we can decompose the value into individual one letter (global) variables with the `decompose()` method.
|
|
590
|
+
E.g.
|
|
591
|
+
|
|
592
|
+
```
|
|
593
|
+
istr(485).decompose("abc")
|
|
594
|
+
```
|
|
595
|
+
will set the global variables `a`, `b` and `c` to be set to `istr(4)`. `istr(8)` and` istr(5)`.
|
|
596
|
+
Note that the length of the letters specifier must be the same as the length of the istr. Furthermore, multiple values for the same variables result in a ValueError.
|
|
597
|
+
|
|
598
|
+
With `istr.compose()`, an istr can be constructed from individual (global) variables.
|
|
599
|
+
E.g.
|
|
600
|
+
|
|
601
|
+
```
|
|
602
|
+
x = 3
|
|
603
|
+
y = 9
|
|
604
|
+
z = 6
|
|
605
|
+
test = istr.compose("xyz")
|
|
606
|
+
```
|
|
607
|
+
Now, `test` will be `istr(396)` .
|
|
561
608
|
|
|
562
609
|
#### Subclassing istr
|
|
610
|
+
|
|
563
611
|
When a class is derived from istr, all methods will return that newly derived class.
|
|
564
612
|
|
|
565
613
|
E.g.
|