istr-python 1.0.0.post0__tar.gz → 1.0.2__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.1
2
2
  Name: istr-python
3
- Version: 1.0.0.post0
3
+ Version: 1.0.2
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
@@ -150,10 +150,10 @@ or even
150
150
  four, five = istr(4, 5)
151
151
  ```
152
152
 
153
- > > [!IMPORTANT]
154
- > >
155
- > > All calculations are strictly integer calculations. That means that if a float or decimal variable is ever produced it will be converted to an int.
156
- > > Also divisions are always floor divisions!
153
+ ##### Important
154
+ >
155
+ > All calculations are strictly integer calculations. That means that if a float or decimal variable is ever produced it will be converted to an int.
156
+ > Also divisions are always floor divisions!
157
157
 
158
158
  #### Use istrs as string
159
159
 
@@ -188,12 +188,13 @@ And
188
188
 
189
189
  is also `istr('444')`
190
190
 
191
- > Note:
191
+ ##### Note
192
+
192
193
  >
193
194
  > It is not allowed to use the `@` operator for two istrs. So, `four @ five` raises a TypeError.
194
-
195
195
  #### istrs that can't be interpreted as an int
196
196
 
197
+
197
198
  Although usualy, istrs are to be interpreted as an int, that's not a requirement.
198
199
 
199
200
  So
@@ -234,7 +235,7 @@ is `False`.
234
235
 
235
236
 
236
237
 
237
- The bool operator works normally on the integer value of an istr. So
238
+ The `bool` operator works normally on the integer value of an istr. So
238
239
 
239
240
  `bool(istr('0'))` ==> `False`
240
241
  `bool(istr('1'))` ==> `True`
@@ -251,6 +252,7 @@ For the `in` operator, an istr is treated as an ordinary string, although it is
251
252
  ```
252
253
  '34' in istr(1234)
253
254
  34 in istr(1234)
255
+
254
256
  ```
255
257
  On the left hand side an istr is always treated as a string:
256
258
  ```
@@ -280,47 +282,39 @@ is
280
282
  ```
281
283
  '0 1 2 3 4 5 6 7 8 9 10 11'
282
284
  ```
285
+ #### Using values that are neither string or numeric to initialize istr
283
286
 
284
- #### Using values to inialitize istr other than numeric value or str
285
- Apart from with simple numeric (to be interpreted as an int) or str, istr can be initialized with
287
+ Apart from with numeric (to be interpreted as an int) or str, istr can be initialized with
286
288
  several other types:
287
289
 
288
- - if a dict (or subtype of dict), the same type dict will be returned with all *values* istr'ed
289
290
 
290
- ```
291
- istr({0: 0, 1: 1, 2: 4}) ==> {0: istr('0'), 1: istr('1'), 2: istr('4')}
292
- ```
291
+ - if a dict (or subtype of dict), the same type dict will be returned with all *values* istr'ed
293
292
 
294
293
  - if an iterator, the iterator will be mapped with istr
295
294
 
296
- ```
297
- istr(i * i for i in range(3)) ==> <map object>
298
- list(istr(i * i for i in range(3))) ==> [istr('0'), istr('1'), istr('4')]
299
- ```
300
-
301
295
  - if an iterable, the same type will be returned with all elements istr'ed
302
296
 
303
- ```
297
+ ```
304
298
  istr([0, 1, 4]) ==> [istr('0'), istr('1'), istr('4')]
305
299
  istr((0, 1, 4)) ==> (istr('0'), istr('1'), istr('4'))
306
- istr({0, 1, 4}) ==> `{istr('4'), istr('0'), istr('1')} # or similar
307
- ```
300
+ istr({0, 1, 4}) ==> `{istr('4'), istr('0'), istr('1')} # or similar
301
+ ```
308
302
 
309
303
  - if a range, an istr.range instance will be returned
310
304
 
311
- ```
312
- istr(range(3))` ==> `istr.range(3)
313
- list(istr(range(3)))` ==> `[istr('0'), istr('1'), istr('2')]
314
- len(istr(range(3)))` ==> `3
315
- ```
305
+ ```
306
+ istr(range(3)) ==> istr.range(3)
307
+ list(istr(range(3))) ==> [istr('0'), istr('1'), istr('2')]
308
+ len(istr(range(3))) ==> 3
309
+ ```
316
310
 
317
311
  - if an istr.range instance, the same istr.range will be returned
318
312
 
319
313
  - if an istr, the same istr will be used
320
314
 
321
- ```
315
+ ```
322
316
  istr(istr('4')) ==> istr ('4')
323
- ```
317
+ ```
324
318
 
325
319
  #### More than one parameter for istr
326
320
  It is possible to give more than one parameter, in which case a tuple
@@ -355,7 +349,7 @@ istr(n100).all_distinct() ==> False
355
349
 
356
350
  #### reverse an istr
357
351
 
358
- The method `istr.reversed()` will return the an istr with the reversed content:
352
+ The method `istr.reversed()` will return an istr with the reversed content:
359
353
  ```
360
354
  istr(456).reversed() ==> istr('654')
361
355
  istr('0456').reversed() ==> istr('6540')
@@ -365,13 +359,13 @@ The same can -of course- be achieved with
365
359
  istr(456)[::-1] ==> istr('654')
366
360
  istr('0456')[::-1] ==> istr('6540')
367
361
  ```
368
- > > [!NOTE]
369
- > >
370
- > > It is possible to reverse a negative istr, but the result can't be interpreted as an int anymore.
371
- > >
372
- > > ```
373
- > > istr(-456) ==> TypeError
374
- > > ```
362
+ ##### Note
363
+ >
364
+ > It is possible to reverse a negative istr, but the result can't be interpreted as an int anymore.
365
+ >
366
+ > ```
367
+ > istr(-456).reversed() ==> TypeError
368
+ > ```
375
369
 
376
370
  #### enumerate with istrs
377
371
 
@@ -379,8 +373,8 @@ The `istr.enumerate` method can be used just as the builtin enumerate function.
379
373
  The iteration counter however is an istr rather than an int. E.g.
380
374
 
381
375
  ```
382
- for i, c in istr.enumerate('abc'):
383
- print(f'{repr(i)} {c}')
376
+ for i, c in istr.enumerate('abc'):
377
+ print(f'{repr(i)} {c}')
384
378
  ```
385
379
  prints
386
380
  ```
@@ -414,7 +408,8 @@ The given argument(s) result in a range of digits.
414
408
  - `<n>` ==> n
415
409
  - `<n-m>` ==> n, n+1, ..., m
416
410
  - `-n>` ==> 0, 1, ... n
417
- - `n->` ==> n, n+1, ..., 9
411
+ - `n->` ==> n, n+1, ..., 9 if n is numeric (0-9), n, n+1, ... Z if n is a letter
412
+ - `'-'` ==> 0, 1, ..., 9
418
413
  - `''` ==> 0, 1, ..., 9
419
414
 
420
415
  (n and m must be digits between 0 and 9 or letters letters between A and Z)
@@ -460,9 +455,9 @@ will print `jstr('20')`
460
455
 
461
456
  It is possible to control the way an `istr` instance will be repr'ed.
462
457
 
463
- By default, the `istr(5)` is represented as `istr('5')`.
458
+ By default, `istr(5)` is represented as `istr('5')`.
464
459
 
465
- With the istr.repr_mode() context manager, that can be changed:
460
+ With the `istr.repr_mode()` context manager, that can be changed:
466
461
  ```
467
462
  with istr.repr_mode('str'):
468
463
  five = istr(5)
@@ -480,7 +475,7 @@ This will print
480
475
  5
481
476
  istr('5')
482
477
  ```
483
- If the repr_mode is `'int'` and the istr can't be interpreted as an int the string `nan` (not a number) will be returned:
478
+ If the repr_mode is `'int'` and the istr can't be interpreted as an int the string `?` will be returned:
484
479
 
485
480
  ```
486
481
  with istr.repr_mode('int'):
@@ -491,12 +486,12 @@ If the repr_mode is `'int'` and the istr can't be interpreted as an int the stri
491
486
  This will print
492
487
 
493
488
  ```
494
- nan
489
+ ?
495
490
  ```
496
491
 
497
- > > [!NOTE]
498
- > >
499
- > > The way an `istr` is represented is determined at initialization.
492
+ ##### Note
493
+ >
494
+ > The way an `istr` is represented is determined at initialization.
500
495
 
501
496
  It is also possible to set the repr mode without a context manager:
502
497
 
@@ -530,13 +525,13 @@ with istr.base(16):
530
525
  a = istr('7fff')
531
526
  print(int(a))
532
527
 
533
- b = istr(15)
528
+ b = istr(127)
534
529
  print(repr(b))
535
530
  ```
536
531
  This will result in
537
532
  ```
538
533
  32767
539
- istr('F')
534
+ istr('7F')
540
535
  ```
541
536
  All calculations are done in the decimal 10 system.
542
537
 
@@ -559,7 +554,7 @@ will result in `10`.
559
554
 
560
555
  #### Changing the format of the string
561
556
 
562
- When an istr is initialized with a string the istr will be just stored as such.
557
+ When an istr is initialized with a string the istr will be always stored as such.
563
558
 
564
559
  ```
565
560
  repr('4')) ==> istr('4')
@@ -573,7 +568,7 @@ For initializing with an int (or other numeric) value, the string is by default
573
568
  repr(4)) ==> istr('4')
574
569
  ```
575
570
 
576
- With the `istr.int_format()` context manager this behavior can be changed.
571
+ With the `istr.int_format()` context manager this behavior can be changed.
577
572
  If the format specifier is a number, most likely a single digit, that
578
573
  will be the minimum number of characters in the string:
579
574
 
@@ -606,24 +601,10 @@ istr('012')
606
601
  istr('123')
607
602
  istr('1234')
608
603
  ```
609
- > > [!NOTE]
610
- > >
611
- > > if a string is used to initialize an istr AND that string can be interpreted as an int. the string will reformatted:
612
- > >
613
- > > ```
614
- > > with istr.int_format('03'):
615
- > > print(repr(istr(12)))
616
- > > ```
617
- > >
618
- > > will result in
619
- > >
620
- > > ```
621
- > > istr('0012')
622
- > > ```
604
+
605
+ ##### Note
623
606
  >
624
- > > [!NOTE]
625
- > >
626
- > > For bases other than 10, the string will never be reformatted!
607
+ > For bases other than 10, the string will never be reformatted!
627
608
 
628
609
  ### Overview of operations
629
610
 
@@ -663,6 +644,8 @@ There's an extensive pytest script in the `\tests` directory.
663
644
 
664
645
  This script also shows clearly the ways istr can be used, including several edge cases. Highly recommended to have a look at.
665
646
 
647
+
648
+
666
649
  ### Badges
667
650
  ![PyPI](https://img.shields.io/pypi/v/istr-python) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/istr-python) ![PyPI - Implementation](https://img.shields.io/pypi/implementation/istr-python)
668
651