peek-python 25.0.9__tar.gz → 25.0.11__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.
- {peek_python-25.0.9 → peek_python-25.0.11}/PKG-INFO +74 -69
- {peek_python-25.0.9 → peek_python-25.0.11}/README.md +73 -68
- {peek_python-25.0.9 → peek_python-25.0.11}/peek/peek.py +1 -1
- {peek_python-25.0.9 → peek_python-25.0.11}/peek_python.egg-info/PKG-INFO +74 -69
- {peek_python-25.0.9 → peek_python-25.0.11}/pyproject.toml +1 -1
- {peek_python-25.0.9 → peek_python-25.0.11}/license.txt +0 -0
- {peek_python-25.0.9 → peek_python-25.0.11}/peek/__init__.py +0 -0
- {peek_python-25.0.9 → peek_python-25.0.11}/peek_python.egg-info/SOURCES.txt +0 -0
- {peek_python-25.0.9 → peek_python-25.0.11}/peek_python.egg-info/dependency_links.txt +0 -0
- {peek_python-25.0.9 → peek_python-25.0.11}/peek_python.egg-info/requires.txt +0 -0
- {peek_python-25.0.9 → peek_python-25.0.11}/peek_python.egg-info/top_level.txt +0 -0
- {peek_python-25.0.9 → peek_python-25.0.11}/setup.cfg +0 -0
- {peek_python-25.0.9 → peek_python-25.0.11}/tests/test_peek.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: peek-python
|
|
3
|
-
Version: 25.0.
|
|
3
|
+
Version: 25.0.11
|
|
4
4
|
Summary: peek - debugging and benchmarking made easy
|
|
5
5
|
Author-email: Ruud van der Ham <rt.van.der.ham@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/salabim/peek
|
|
@@ -20,13 +20,13 @@ Requires-Dist: tomli>=2.2.1
|
|
|
20
20
|
|
|
21
21
|
<img src="https://www.salabim.org/peek/peek_logo1.png">
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
## Introduction
|
|
24
24
|
|
|
25
25
|
Do you use `print()` or `log()` to debug your code?
|
|
26
26
|
If so, peek will make printing debug information really easy.
|
|
27
27
|
And on top of that, you get some basic benchmarking functionality.
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
## Table of contents
|
|
30
30
|
|
|
31
31
|
* [Installation](#installation)
|
|
32
32
|
|
|
@@ -74,8 +74,10 @@ And on top of that, you get some basic benchmarking functionality.
|
|
|
74
74
|
|
|
75
75
|
* [Differences with IceCream](#differences-with-icecream)
|
|
76
76
|
|
|
77
|
+
* [Contact info](#contact-info)
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
|
|
80
|
+
## Installation
|
|
79
81
|
|
|
80
82
|
Installing peek with pip is easy.
|
|
81
83
|
```
|
|
@@ -98,7 +100,7 @@ Note that peek requires the `asttokens`, `colorama`, `executing`. `six`, `toml
|
|
|
98
100
|
>
|
|
99
101
|
> The GitHub repository can be found on https://github.com/salabim/peek .
|
|
100
102
|
|
|
101
|
-
|
|
103
|
+
## Importing peek
|
|
102
104
|
|
|
103
105
|
All you need is:
|
|
104
106
|
|
|
@@ -116,7 +118,7 @@ Note that after this, `peek` is automatically a builtin and can thus be used in
|
|
|
116
118
|
importing it there.
|
|
117
119
|
|
|
118
120
|
|
|
119
|
-
|
|
121
|
+
## Inspect variables and expressions
|
|
120
122
|
|
|
121
123
|
Have you ever printed variables or expressions to debug your program? If you've
|
|
122
124
|
ever typed something like
|
|
@@ -181,7 +183,7 @@ This will result in:
|
|
|
181
183
|
|
|
182
184
|
<img src="https://www.salabim.org/peek/peek_picture1.png" width=50%>
|
|
183
185
|
|
|
184
|
-
|
|
186
|
+
## Inspect execution
|
|
185
187
|
|
|
186
188
|
Have you ever used `print()` to determine which parts of your program are
|
|
187
189
|
executed, and in which order they're executed? For example, if you've ever added
|
|
@@ -213,7 +215,7 @@ prints something like
|
|
|
213
215
|
add2(1000)=1002
|
|
214
216
|
```
|
|
215
217
|
|
|
216
|
-
|
|
218
|
+
## Return Value
|
|
217
219
|
|
|
218
220
|
`peek()` returns its argument(s), so `peek()` can easily be inserted into
|
|
219
221
|
pre-existing code.
|
|
@@ -229,7 +231,7 @@ prints
|
|
|
229
231
|
add2(1000)=1002
|
|
230
232
|
b=1002
|
|
231
233
|
```
|
|
232
|
-
|
|
234
|
+
## Debug entry and exit of function calls
|
|
233
235
|
|
|
234
236
|
When you apply `peek()` as a decorator to a function or method, both the entry and exit can be tracked.
|
|
235
237
|
The (keyword) arguments passed will be shown and upon return, the return value.
|
|
@@ -263,7 +265,7 @@ called mul(5, 7)
|
|
|
263
265
|
35
|
|
264
266
|
```
|
|
265
267
|
|
|
266
|
-
|
|
268
|
+
## Benchmarking with peek
|
|
267
269
|
|
|
268
270
|
If you decorate a function or method with peek(), you will be offered the duration between entry and exit (in seconds) as a bonus.
|
|
269
271
|
|
|
@@ -333,7 +335,7 @@ might print something like:
|
|
|
333
335
|
duration=1.0001721999999997
|
|
334
336
|
```
|
|
335
337
|
|
|
336
|
-
|
|
338
|
+
## Configuration
|
|
337
339
|
|
|
338
340
|
For the configuration, it is important to realize that `peek` is an instance of a class, which has
|
|
339
341
|
a number of configuration attributes:
|
|
@@ -438,7 +440,8 @@ peek2.show_time = True
|
|
|
438
440
|
```
|
|
439
441
|
After this `peek1` and `peek2` will behave similarly (but they are not the same!)
|
|
440
442
|
|
|
441
|
-
|
|
443
|
+
### prefix / pr
|
|
444
|
+
|
|
442
445
|
```
|
|
443
446
|
peek('world', prefix='hello -> ')
|
|
444
447
|
```
|
|
@@ -462,7 +465,7 @@ prints something like
|
|
|
462
465
|
1613635601 hello='world'
|
|
463
466
|
```
|
|
464
467
|
|
|
465
|
-
|
|
468
|
+
output
|
|
466
469
|
This will allow the output to be handled by something else than the default (output being written to stdout).
|
|
467
470
|
|
|
468
471
|
The `output` attribute can be
|
|
@@ -519,7 +522,7 @@ peek.output = "stderr"
|
|
|
519
522
|
```
|
|
520
523
|
to print to stderr.
|
|
521
524
|
|
|
522
|
-
|
|
525
|
+
### serialize
|
|
523
526
|
This will allow to specify how argument values are to be serialized to displayable strings.
|
|
524
527
|
The default is `pformat` (from `pprint`), but this can be changed.
|
|
525
528
|
For example, to handle non-standard datatypes in a custom fashion.
|
|
@@ -543,7 +546,7 @@ prints
|
|
|
543
546
|
7, hello='world' [len=5], zero_to_six=[0, 1, 2, 3, 4, 5, 6] [len=7]
|
|
544
547
|
```
|
|
545
548
|
|
|
546
|
-
|
|
549
|
+
### show_line_number / sln
|
|
547
550
|
If True, adds the `peek()` call's line number and possibly the filename and parent function to `peek()`'s output.
|
|
548
551
|
|
|
549
552
|
```
|
|
@@ -574,7 +577,7 @@ Note that if you call `peek` without any arguments, the line number is always sh
|
|
|
574
577
|
|
|
575
578
|
See below for an explanation of the information provided.
|
|
576
579
|
|
|
577
|
-
|
|
580
|
+
### show_time / st
|
|
578
581
|
If True, adds the current time to `peek()`'s output.
|
|
579
582
|
|
|
580
583
|
```
|
|
@@ -587,7 +590,7 @@ prints something like
|
|
|
587
590
|
@ 13:01:47.588125 ==> hello='world'
|
|
588
591
|
```
|
|
589
592
|
|
|
590
|
-
|
|
593
|
+
### show_delta / sd
|
|
591
594
|
If True, adds the number of seconds since the start of the program to `peek()`'s output.
|
|
592
595
|
```
|
|
593
596
|
import time
|
|
@@ -604,20 +607,20 @@ delta=0.088 ==> english='hallo world'
|
|
|
604
607
|
delta=1.091 ==> french='bonjour le monde'
|
|
605
608
|
```
|
|
606
609
|
|
|
607
|
-
|
|
610
|
+
### show_enter / se
|
|
608
611
|
When used as a decorator or context manager, by default, peek ouputs a line when the decorated the
|
|
609
612
|
function is called or the context manager is entered.
|
|
610
613
|
|
|
611
614
|
With `show_enter=False` this line can be suppressed.
|
|
612
615
|
|
|
613
|
-
|
|
616
|
+
### show_exit / sx
|
|
614
617
|
When used as a decorator or context manager, by default, peek ouputs a line when the decorated the
|
|
615
618
|
function returned or the context manager is exited.
|
|
616
619
|
|
|
617
620
|
With `show_exit=False` this line can be suppressed.
|
|
618
621
|
|
|
619
622
|
|
|
620
|
-
|
|
623
|
+
### show_traceback
|
|
621
624
|
When show_traceback is True, the ordinary output of peek() will be followed by a printout of the
|
|
622
625
|
traceback, similar to an error traceback.
|
|
623
626
|
|
|
@@ -645,7 +648,7 @@ prints something like
|
|
|
645
648
|
```
|
|
646
649
|
The `show_traceback` functionality is also available when peek is used as a decorator or context manager.
|
|
647
650
|
|
|
648
|
-
|
|
651
|
+
### line_length / ll
|
|
649
652
|
This attribute is used to specify the line length (for wrapping). The default is 80.
|
|
650
653
|
Peek tries to keep all output on one line, but if it can't it will wrap:
|
|
651
654
|
|
|
@@ -663,7 +666,7 @@ d=
|
|
|
663
666
|
d={'a1': 1, 'a2': {'a': 1, 'b': 1, 'c': 3}, 'a3': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}
|
|
664
667
|
```
|
|
665
668
|
|
|
666
|
-
|
|
669
|
+
### color / col and color_value / colv
|
|
667
670
|
The color attribute is used to specify the color of the output.
|
|
668
671
|
|
|
669
672
|
There's a choice of `"black"`, `"white"`, `"red"`, `"green"`, `"blue"`, `"cyan"`, `"magenta"`, `"yellow"`, `" dark_black"`, `"dark_white"`, `"dark_red"`, `"dark_green"`, `"dark_blue"`, `"dark_cyan"`, `"dark_magenta"` and `"dark_yellow"`:
|
|
@@ -713,7 +716,7 @@ repr(peek.ANSI.red)='\x1b[1;31m'
|
|
|
713
716
|
|
|
714
717
|
------
|
|
715
718
|
|
|
716
|
-
|
|
719
|
+
### use_color
|
|
717
720
|
|
|
718
721
|
Colors can be ignored completely by using `peek.use_color = False`.
|
|
719
722
|
|
|
@@ -729,7 +732,7 @@ will print `hello=world` once in red and once without color.
|
|
|
729
732
|
|
|
730
733
|
Of course, `use_color` can be specified in a peek.toml file.
|
|
731
734
|
|
|
732
|
-
|
|
735
|
+
### compact
|
|
733
736
|
|
|
734
737
|
This attribute is used to specify the compact parameter for `pformat` (see the pprint documentation
|
|
735
738
|
for details). `compact` is False by default.
|
|
@@ -757,7 +760,7 @@ a=
|
|
|
757
760
|
'0123456789', '0123456789', '0123456789', '0123456789']
|
|
758
761
|
```
|
|
759
762
|
|
|
760
|
-
|
|
763
|
+
### indent
|
|
761
764
|
This attribute is used to specify the indent parameter for `pformat` (see the pprint documentation
|
|
762
765
|
for details). `indent` is 1 by default.
|
|
763
766
|
|
|
@@ -777,7 +780,7 @@ prints
|
|
|
777
780
|
['01234567890012345678900123456789001234567890']]
|
|
778
781
|
```
|
|
779
782
|
|
|
780
|
-
|
|
783
|
+
### depth
|
|
781
784
|
This attribute is used to specify the depth parameter for `pformat` (see the pprint documentation
|
|
782
785
|
for details). `depth` is `1000000` by default.
|
|
783
786
|
|
|
@@ -800,7 +803,7 @@ prints
|
|
|
800
803
|
['01234567890012345678900123456789001234567890', [...]]]]
|
|
801
804
|
```
|
|
802
805
|
|
|
803
|
-
|
|
806
|
+
### wrap_indent
|
|
804
807
|
This specifies the indent string if the output does not fit in the line_length (has to be wrapped).
|
|
805
808
|
Rather than a string, wrap_indent can be also be an integer, in which case the wrap_indent will be that amount of blanks.
|
|
806
809
|
The default is 4 blanks.
|
|
@@ -829,8 +832,9 @@ d=
|
|
|
829
832
|
'a3': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}
|
|
830
833
|
```
|
|
831
834
|
|
|
832
|
-
|
|
835
|
+
### enabled
|
|
833
836
|
Can be used to disable the output:
|
|
837
|
+
|
|
834
838
|
```
|
|
835
839
|
peek.enabled = False
|
|
836
840
|
s = 'the world is '
|
|
@@ -844,7 +848,7 @@ s + 'on fire.'='the world is on fire.'
|
|
|
844
848
|
```
|
|
845
849
|
and nothing about a perfect world.
|
|
846
850
|
|
|
847
|
-
|
|
851
|
+
### sort_dicts
|
|
848
852
|
By default, peek does not sort dicts (printed by pprint). However, it is possible to get the
|
|
849
853
|
default pprint behaviour (i.e. sorting dicts) with the sorted_dicts attribute:
|
|
850
854
|
|
|
@@ -861,9 +865,7 @@ world={'EN': 'world', 'NL': 'wereld', 'FR': 'monde', 'DE': 'Welt'}
|
|
|
861
865
|
world={'DE': 'Welt', 'EN': 'world', 'FR': 'monde', 'NL': 'wereld'}
|
|
862
866
|
```
|
|
863
867
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
## underscore_numbers / un
|
|
868
|
+
### underscore_numbers / un
|
|
867
869
|
|
|
868
870
|
By default, peek does not add underscores in big numbers (printed by pprint). However, it is possible to get the
|
|
869
871
|
default pprint behaviour with the underscore_numbers attribute:
|
|
@@ -881,9 +883,7 @@ numbers={'one': 1, 'thousand': 1_000, 'million': 1_000_000, 'x1234567890': 1_234
|
|
|
881
883
|
numbers={'one': 1, 'thousand': 1000, 'million': 1000000, 'x1234567890': 1234567890}
|
|
882
884
|
```
|
|
883
885
|
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
## seperator / sep
|
|
886
|
+
### seperator / sep
|
|
887
887
|
|
|
888
888
|
By default, pairs (on one line) are separated by `", "`.
|
|
889
889
|
It is possible to change this with the attribute ` separator`:
|
|
@@ -902,10 +902,11 @@ a='abcd', (b,c)=(1, 1000), d=['p', 'e', 'e', 'k']
|
|
|
902
902
|
a='abcd' | (b,c)=(1, 1000) | d=['p', 'e', 'e', 'k']
|
|
903
903
|
```
|
|
904
904
|
|
|
905
|
-
|
|
905
|
+
### context_separator
|
|
906
906
|
|
|
907
907
|
By default the line_number, time and/or delta are followed by ` ==> `.
|
|
908
908
|
It is possible to change this with the attribute `context_separator`:
|
|
909
|
+
|
|
909
910
|
```
|
|
910
911
|
a = "abcd"
|
|
911
912
|
peek(a,show_time=True)
|
|
@@ -916,7 +917,7 @@ prints:
|
|
|
916
917
|
@ 09:05:38.693840 ==> a='abcd'
|
|
917
918
|
@ 09:05:38.707914 ➜ a='abcd'
|
|
918
919
|
```
|
|
919
|
-
|
|
920
|
+
### equals_separator
|
|
920
921
|
By default name of a variable and its value are separated by `= `.
|
|
921
922
|
It is possible to change this with the attribute `equals_separator`:
|
|
922
923
|
|
|
@@ -930,7 +931,7 @@ prints:
|
|
|
930
931
|
a='abcd'
|
|
931
932
|
a == 'abcd'
|
|
932
933
|
```
|
|
933
|
-
|
|
934
|
+
### quote_string / qs
|
|
934
935
|
If True (the default setting) strings will be displayed with surrounding quotes (like repr).
|
|
935
936
|
If False, string will be displayed without surrounding quotes (like str).
|
|
936
937
|
E.g.
|
|
@@ -949,7 +950,7 @@ This will print:
|
|
|
949
950
|
>
|
|
950
951
|
> This setting does not influence how strings are displayed within other data structures, like dicts and lists.
|
|
951
952
|
|
|
952
|
-
|
|
953
|
+
### format / fmt
|
|
953
954
|
With the format attribute, it is possible to apply a format specifier to each of the values to be printed, like
|
|
954
955
|
```
|
|
955
956
|
test_float = 1.3
|
|
@@ -983,7 +984,7 @@ test_float=01.300, test_integer=0010, test_string= test, test_dict={'one':
|
|
|
983
984
|
|
|
984
985
|
Of course, format may be put in a peek.toml file.
|
|
985
986
|
|
|
986
|
-
|
|
987
|
+
### values_only / vo
|
|
987
988
|
|
|
988
989
|
If False (the default), both the left-hand side (if possible) and the
|
|
989
990
|
value will be printed. If True, the left hand side will be suppressed:
|
|
@@ -999,7 +1000,7 @@ hello='world', 2 * hello='worldworld'
|
|
|
999
1000
|
'world', 'worldworld'
|
|
1000
1001
|
```
|
|
1001
1002
|
|
|
1002
|
-
|
|
1003
|
+
### values_only_for_fstrings / voff
|
|
1003
1004
|
If False (the default), both the original f-string and the
|
|
1004
1005
|
value will be printed for f-strings.
|
|
1005
1006
|
If True, the left_hand side will be suppressed in case of an f-string:
|
|
@@ -1019,7 +1020,7 @@ x=1.230e+01
|
|
|
1019
1020
|
Note that if `values_only` is True, f-string will be suppressed, regardless of `values_only_for_fstrings`.
|
|
1020
1021
|
|
|
1021
1022
|
|
|
1022
|
-
|
|
1023
|
+
### end
|
|
1023
1024
|
|
|
1024
1025
|
The `end` attribute works like the end parameter of print. By default, `end` is "\n".
|
|
1025
1026
|
This can be useful to have several peek outputs on one line, like:
|
|
@@ -1045,7 +1046,7 @@ peek('')
|
|
|
1045
1046
|
>
|
|
1046
1047
|
> `\r` does not work under Pythonista.
|
|
1047
1048
|
|
|
1048
|
-
|
|
1049
|
+
### return_none
|
|
1049
1050
|
Normally, `peek()`returns the values passed directly, which is usually fine. However, when used in a notebook
|
|
1050
1051
|
or REPL, that value will be shown, and that can be annoying. Therefore, if `return_none`is True, `peek()`will
|
|
1051
1052
|
return None and thus not show anything.
|
|
@@ -1065,7 +1066,7 @@ a=3, b=4
|
|
|
1065
1066
|
None
|
|
1066
1067
|
```
|
|
1067
1068
|
|
|
1068
|
-
|
|
1069
|
+
### delta
|
|
1069
1070
|
The delta attribute can be used to (re)set the current delta, e.g.
|
|
1070
1071
|
```
|
|
1071
1072
|
peek.delta = 0
|
|
@@ -1073,7 +1074,7 @@ print(peek.delta)
|
|
|
1073
1074
|
```
|
|
1074
1075
|
prints a value that id slightly more than 0.
|
|
1075
1076
|
|
|
1076
|
-
|
|
1077
|
+
### print_like / print
|
|
1077
1078
|
When print_like (or print) is False, peek will work by expanding the arguments to description/serialized value pairs.
|
|
1078
1079
|
But, when print_like is True, peek becomes a kind of supercharged print:
|
|
1079
1080
|
|
|
@@ -1093,7 +1094,7 @@ You can also use peek.print (see below).
|
|
|
1093
1094
|
>
|
|
1094
1095
|
> Of course, `print_like` can be put in a **peek.toml** file.
|
|
1095
1096
|
|
|
1096
|
-
|
|
1097
|
+
## Use peek.print to use peek like print with extras
|
|
1097
1098
|
The method `peek.print` allows peek to be used as alternative to print. Note that `peek.print` applies the `color`, `context_separator`, `enabled`, `end`, `filter` and `output`, `separator_print`, `show_delta` and `show_time`. It is also possible to redirect the output to a string with `as_str`.
|
|
1098
1099
|
|
|
1099
1100
|
So,
|
|
@@ -1142,7 +1143,7 @@ peek.sep = "|" # sets the 'normal' peek separator
|
|
|
1142
1143
|
> `peek.print` does not obey the line length and will always return None (unless as_str is True).
|
|
1143
1144
|
|
|
1144
1145
|
|
|
1145
|
-
|
|
1146
|
+
## Peeking locals and globals
|
|
1146
1147
|
It is possible to get the name and values of all local or global variables.
|
|
1147
1148
|
|
|
1148
1149
|
To do that, just put `locals` or `globals` in the call to peek, e.g.:
|
|
@@ -1170,7 +1171,7 @@ will print all global variables, apart from those starting with `__`
|
|
|
1170
1171
|
>
|
|
1171
1172
|
> You should not add parentheses after `locals` or `globals` for peek to work properly!
|
|
1172
1173
|
|
|
1173
|
-
|
|
1174
|
+
## Return a string instead of sending to output
|
|
1174
1175
|
|
|
1175
1176
|
`peek(*args, as_str=True)` is like `peek(*args)` but the output is returned as a string instead
|
|
1176
1177
|
of written to output.
|
|
@@ -1203,7 +1204,7 @@ prints
|
|
|
1203
1204
|
'hello=world\n'
|
|
1204
1205
|
```
|
|
1205
1206
|
|
|
1206
|
-
|
|
1207
|
+
## Disabling peek's output
|
|
1207
1208
|
|
|
1208
1209
|
```
|
|
1209
1210
|
peek1 = peek.fork(show_delta=True)
|
|
@@ -1229,7 +1230,7 @@ Of course `peek()` continues to return its arguments when disabled.
|
|
|
1229
1230
|
|
|
1230
1231
|
It is also possible to suppress output with the provided attribute (see above).
|
|
1231
1232
|
|
|
1232
|
-
|
|
1233
|
+
## Using filter to control peek output
|
|
1233
1234
|
|
|
1234
1235
|
It is possible to define a filter function that determines whether peek output should be suppressed
|
|
1235
1236
|
By default, the filter is defined as "" denoting no filter.
|
|
@@ -1254,11 +1255,11 @@ As an alternative to `enabled` we can also say
|
|
|
1254
1255
|
peek.filter = "False"
|
|
1255
1256
|
```
|
|
1256
1257
|
|
|
1257
|
-
|
|
1258
|
+
## Copying to the clipboard
|
|
1258
1259
|
|
|
1259
1260
|
It is possible to copy a value to the clipboard. There are two ways:
|
|
1260
1261
|
|
|
1261
|
-
|
|
1262
|
+
#### With peek(to_clipboard=True)
|
|
1262
1263
|
|
|
1263
1264
|
With the optional keyword argument, *to_clipboard*:
|
|
1264
1265
|
|
|
@@ -1282,7 +1283,7 @@ Note that *to_clipboard* is a peek attribute.
|
|
|
1282
1283
|
|
|
1283
1284
|
If as_str==True, to_clipboard is ignored.
|
|
1284
1285
|
|
|
1285
|
-
|
|
1286
|
+
#### With peek.to_clipboard
|
|
1286
1287
|
|
|
1287
1288
|
Just use peek.to_clipboard to copy any value to the clipboard. So,
|
|
1288
1289
|
```
|
|
@@ -1297,14 +1298,14 @@ If the confirmation message is not wanted, just add confirm=False, like
|
|
|
1297
1298
|
peek.to_clipboard(part1, confirm=False)
|
|
1298
1299
|
```
|
|
1299
1300
|
|
|
1300
|
-
|
|
1301
|
+
#### General
|
|
1301
1302
|
|
|
1302
1303
|
Implementation detail: the clipboard functionality uses pyperclip, apart from under Pythonista, where the
|
|
1303
1304
|
builtin clipboard module is used.
|
|
1304
1305
|
|
|
1305
1306
|
This functionality is particularly useful for entering an answer of an *Advent of Code* solution to the site.
|
|
1306
1307
|
|
|
1307
|
-
|
|
1308
|
+
## Interpreting the line number information
|
|
1308
1309
|
|
|
1309
1310
|
When `show_line_number` is True or peek() is used without any parameters, the output will contain the line number like:
|
|
1310
1311
|
```
|
|
@@ -1320,7 +1321,7 @@ And finally when used in a function or method, that function/method will be show
|
|
|
1320
1321
|
```
|
|
1321
1322
|
The parent function can be suppressed by setting `show_line_number` or `sln` to `"n"` or `"no parent"`.
|
|
1322
1323
|
|
|
1323
|
-
|
|
1324
|
+
## Configuring at import time
|
|
1324
1325
|
|
|
1325
1326
|
It can be useful to configure peek at import time. This can be done by providing a `peek.toml` file which
|
|
1326
1327
|
can contain any attribute configuration overriding the standard settings.
|
|
@@ -1364,7 +1365,7 @@ quote_string = false
|
|
|
1364
1365
|
|
|
1365
1366
|
|
|
1366
1367
|
|
|
1367
|
-
|
|
1368
|
+
## Working with multiple instances of peek
|
|
1368
1369
|
|
|
1369
1370
|
Normally, only the `peek` object is used.
|
|
1370
1371
|
|
|
@@ -1390,7 +1391,7 @@ There are several ways to obtain a new instance of peek:
|
|
|
1390
1391
|
|
|
1391
1392
|
In either case, attributes can be added to override the default ones.
|
|
1392
1393
|
|
|
1393
|
-
|
|
1394
|
+
#### Example
|
|
1394
1395
|
```
|
|
1395
1396
|
peek_with_line_number = peek.fork(show_line_number=True)
|
|
1396
1397
|
peek_with_new_prefix = peek.new(prefix="==> ")
|
|
@@ -1421,10 +1422,10 @@ hello == 'world'
|
|
|
1421
1422
|
peek_cm exit in 0.001843 seconds
|
|
1422
1423
|
```
|
|
1423
1424
|
|
|
1424
|
-
|
|
1425
|
+
### ignore_toml
|
|
1425
1426
|
With `peek.new(ignore_toml=True)` an instance of peek without having applied any toml configuration file will be returned. That can be useful when guaranteeing the same output in several setups.
|
|
1426
1427
|
|
|
1427
|
-
|
|
1428
|
+
#### Example
|
|
1428
1429
|
Suppose we have a `peek.toml` file in the current directory with the contents
|
|
1429
1430
|
```
|
|
1430
1431
|
{prefix="==>"}
|
|
@@ -1445,14 +1446,14 @@ prints
|
|
|
1445
1446
|
hello='world'
|
|
1446
1447
|
```
|
|
1447
1448
|
|
|
1448
|
-
|
|
1449
|
+
## Test script
|
|
1449
1450
|
|
|
1450
1451
|
On GitHub is a file `test_peek.py` that tests (and thus also demonstrates) most of the functionality
|
|
1451
1452
|
of peek.
|
|
1452
1453
|
|
|
1453
1454
|
It is very useful to have a look at the tests to see the features (some may be not covered (yet) in this readme).
|
|
1454
1455
|
|
|
1455
|
-
|
|
1456
|
+
## Using peek in a REPL
|
|
1456
1457
|
|
|
1457
1458
|
Peek may be used in a REPL, but with limited functionality:
|
|
1458
1459
|
* all arguments are just presented as such, i.e. no left-hand side, e.g.
|
|
@@ -1471,13 +1472,13 @@ Peek may be used in a REPL, but with limited functionality:
|
|
|
1471
1472
|
> Under Python >=3.13 most of the normal peek functionality is available in the REPL. A reason to upgrade!
|
|
1472
1473
|
|
|
1473
1474
|
|
|
1474
|
-
|
|
1475
|
+
## Limitations
|
|
1475
1476
|
|
|
1476
1477
|
It is not possible to use peek:
|
|
1477
1478
|
* from a frozen application (e.g. packaged with PyInstaller)
|
|
1478
1479
|
* when the underlying source code has changed during execution
|
|
1479
1480
|
|
|
1480
|
-
|
|
1481
|
+
## Changelog
|
|
1481
1482
|
|
|
1482
1483
|
The changelog can be found here:
|
|
1483
1484
|
|
|
@@ -1485,7 +1486,7 @@ The changelog can be found here:
|
|
|
1485
1486
|
* https://salabim.org/peek/changelog
|
|
1486
1487
|
|
|
1487
1488
|
|
|
1488
|
-
|
|
1489
|
+
## Acknowledgement
|
|
1489
1490
|
|
|
1490
1491
|
The **peek** package is inspired by the **IceCream** package, but is a nearly complete rewrite. See https://github.com/gruns/icecream
|
|
1491
1492
|
|
|
@@ -1493,7 +1494,7 @@ Many thanks to the author Ansgar Grunseid / grunseid.com / grunseid@gmail.com .
|
|
|
1493
1494
|
|
|
1494
1495
|
The peek package is a rebrand of the **ycecream** package, with many enhancements.
|
|
1495
1496
|
|
|
1496
|
-
|
|
1497
|
+
## Differences with IceCream
|
|
1497
1498
|
|
|
1498
1499
|
The peek module was originally a fork of **IceCream**, but has many differences:
|
|
1499
1500
|
|
|
@@ -1530,9 +1531,13 @@ test script pytest unittest
|
|
|
1530
1531
|
colorize *) yes, off by default yes, on by default
|
|
1531
1532
|
-----------------------------------------------------------------------------------------
|
|
1532
1533
|
*) peek allows selection of colors, whereas IceCream does coloring based on contents.
|
|
1533
|
-
|
|
1534
1534
|
```
|
|
1535
|
-
|
|
1536
|
-
|
|
1535
|
+
## Contact info
|
|
1536
|
+
You can contact Ruud van der Ham, the core developer, via ruud@salabim.org .
|
|
1537
|
+
|
|
1538
|
+
## Badges
|
|
1539
|
+
|
|
1540
|
+
  
|
|
1541
|
+
 
|
|
1537
1542
|

|
|
1538
1543
|
|