peek-python 1.3.20.post2__tar.gz → 1.4.0__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-1.3.20.post2 → peek_python-1.4.0}/PKG-INFO +404 -392
- {peek_python-1.3.20.post2 → peek_python-1.4.0}/README.md +1329 -1317
- {peek_python-1.3.20.post2 → peek_python-1.4.0}/license.txt +1 -1
- {peek_python-1.3.20.post2 → peek_python-1.4.0}/peek/peek.py +42 -25
- {peek_python-1.3.20.post2 → peek_python-1.4.0}/peek_python.egg-info/PKG-INFO +404 -392
- {peek_python-1.3.20.post2 → peek_python-1.4.0}/peek_python.egg-info/SOURCES.txt +1 -1
- {peek_python-1.3.20.post2 → peek_python-1.4.0}/pyproject.toml +1 -1
- peek_python-1.3.20.post2/tests/test_ycecream.py → peek_python-1.4.0/tests/test_peek.py +1197 -1172
- {peek_python-1.3.20.post2 → peek_python-1.4.0}/peek/__init__.py +0 -0
- {peek_python-1.3.20.post2 → peek_python-1.4.0}/peek_python.egg-info/dependency_links.txt +0 -0
- {peek_python-1.3.20.post2 → peek_python-1.4.0}/peek_python.egg-info/top_level.txt +0 -0
- {peek_python-1.3.20.post2 → peek_python-1.4.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: peek-python
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
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/ycecream
|
|
@@ -12,11 +12,11 @@ Requires-Python: >=3.6
|
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: license.txt
|
|
14
14
|
|
|
15
|
-
<img src="https://
|
|
15
|
+
<img src="https://salabim.org/peek/peek_logo.png">
|
|
16
16
|
|
|
17
17
|
# Introduction
|
|
18
18
|
|
|
19
|
-
Do you ever use `print()` or `log()` to debug your code? If so,
|
|
19
|
+
Do you ever use `print()` or `log()` to debug your code? If so, peek will make printing debug information really easy.
|
|
20
20
|
And on top of that, you get some basic benchmarking functionality.
|
|
21
21
|
|
|
22
22
|
# Table of contents
|
|
@@ -31,29 +31,29 @@ And on top of that, you get some basic benchmarking functionality.
|
|
|
31
31
|
|
|
32
32
|
* [Debug entry and exit of function calls](#debug-entry-and-exit-of-function-calls)
|
|
33
33
|
|
|
34
|
-
* [Benchmarking with
|
|
34
|
+
* [Benchmarking with peek](#benchmarking-with-peek)
|
|
35
35
|
|
|
36
36
|
* [Configuration](#configuration)
|
|
37
37
|
|
|
38
38
|
* [Return a string instead of sending to output](#return-a-string-instead-of-sending-to-output)
|
|
39
39
|
|
|
40
|
-
* [Disabling
|
|
40
|
+
* [Disabling peek's output](#disabling-peeks-output)
|
|
41
41
|
|
|
42
|
-
* [Speeding up disabled
|
|
42
|
+
* [Speeding up disabled peek](#speeding-up-disabled-peek)
|
|
43
43
|
|
|
44
|
-
* [Using
|
|
44
|
+
* [Using peek as a substitute for `assert`](#using-peek-as-a-substitute-for-assert)
|
|
45
45
|
|
|
46
46
|
* [Interpreting the line number information](#interpreting-the-line-number-information)
|
|
47
47
|
|
|
48
48
|
* [Configuring at import time](#configuring-at-import-time)
|
|
49
49
|
|
|
50
|
-
* [Working with multiple instances of
|
|
50
|
+
* [Working with multiple instances of peek](#working-with-multiple-instances-of-peek)
|
|
51
51
|
|
|
52
52
|
* [Test script](#test-script)
|
|
53
53
|
|
|
54
|
-
* [Using
|
|
54
|
+
* [Using peek in a REPL](#using-peek-in-a-repl)
|
|
55
55
|
|
|
56
|
-
* [Alternative to `
|
|
56
|
+
* [Alternative to `peek`](#alternative-to-peek)
|
|
57
57
|
|
|
58
58
|
* [Alternative installation](#alternative-installation)
|
|
59
59
|
|
|
@@ -63,21 +63,23 @@ And on top of that, you get some basic benchmarking functionality.
|
|
|
63
63
|
|
|
64
64
|
* [Acknowledgement](#acknowledgement)
|
|
65
65
|
|
|
66
|
+
* [Changelog](#changelog)
|
|
67
|
+
|
|
66
68
|
* [Differences with IceCream](#differences-with-icecream)
|
|
67
69
|
|
|
68
70
|
|
|
69
71
|
# Installation
|
|
70
72
|
|
|
71
|
-
Installing
|
|
73
|
+
Installing peek with pip is easy.
|
|
72
74
|
```
|
|
73
|
-
$ pip install
|
|
75
|
+
$ pip install peek-python
|
|
74
76
|
```
|
|
75
77
|
or when you want to upgrade,
|
|
76
78
|
```
|
|
77
|
-
$ pip install
|
|
79
|
+
$ pip install peek-python --upgrade
|
|
78
80
|
```
|
|
79
81
|
|
|
80
|
-
Alternatively,
|
|
82
|
+
Alternatively, peek.py can be juist copied into you current work directory from GitHub (https://github.com/salabim/peek).
|
|
81
83
|
|
|
82
84
|
No dependencies!
|
|
83
85
|
|
|
@@ -101,39 +103,39 @@ or (for Python >= 3.8 only):
|
|
|
101
103
|
print(f"{add2(1000) =}")
|
|
102
104
|
```
|
|
103
105
|
|
|
104
|
-
then `
|
|
106
|
+
then `peek()` is here to help. With arguments, `peek()` inspects itself and prints
|
|
105
107
|
both its own arguments and the values of those arguments.
|
|
106
108
|
|
|
107
109
|
```
|
|
108
|
-
|
|
110
|
+
import peek
|
|
109
111
|
|
|
110
112
|
def add2(i):
|
|
111
113
|
return i + 2
|
|
112
114
|
|
|
113
|
-
|
|
115
|
+
peek(add2(1000))
|
|
114
116
|
```
|
|
115
117
|
|
|
116
118
|
prints
|
|
117
119
|
```
|
|
118
|
-
|
|
120
|
+
peek| add2(1000): 1002
|
|
119
121
|
```
|
|
120
122
|
|
|
121
123
|
Similarly,
|
|
122
124
|
|
|
123
125
|
```
|
|
124
|
-
|
|
126
|
+
import peek
|
|
125
127
|
class X:
|
|
126
128
|
a = 3
|
|
127
129
|
world = {"EN": "world", "NL": "wereld", "FR": "monde", "DE": "Welt"}
|
|
128
130
|
|
|
129
|
-
|
|
131
|
+
peek(world, X.a)
|
|
130
132
|
```
|
|
131
133
|
|
|
132
134
|
prints
|
|
133
135
|
```
|
|
134
|
-
|
|
136
|
+
peek| world: {"EN": "world", "NL": "wereld", "FR": "monde", "DE": "Welt"}, X.a: 3
|
|
135
137
|
```
|
|
136
|
-
Just give `
|
|
138
|
+
Just give `peek()` a variable or expression and you're done. Sweet, isn't it?
|
|
137
139
|
|
|
138
140
|
|
|
139
141
|
# Inspect execution
|
|
@@ -149,99 +151,99 @@ def add2(i):
|
|
|
149
151
|
print("exit")
|
|
150
152
|
return result
|
|
151
153
|
```
|
|
152
|
-
then `
|
|
154
|
+
then `peek()` helps here, too. Without arguments, `peek()` inspects itself and
|
|
153
155
|
prints the calling line number and -if applicable- the file name and parent function.
|
|
154
156
|
|
|
155
157
|
```
|
|
156
|
-
|
|
158
|
+
import peek
|
|
157
159
|
def add2(i):
|
|
158
|
-
|
|
160
|
+
peek()
|
|
159
161
|
result = i + 2
|
|
160
|
-
|
|
162
|
+
peek()
|
|
161
163
|
return result
|
|
162
|
-
|
|
164
|
+
peek(add2(1000))
|
|
163
165
|
```
|
|
164
166
|
|
|
165
167
|
prints something like
|
|
166
168
|
```
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
peek| #3 in add2()
|
|
170
|
+
peek| #5 in add2()
|
|
171
|
+
peek| add2(1000): 1002
|
|
170
172
|
```
|
|
171
|
-
Just call `
|
|
173
|
+
Just call `peek()` and you're done. Isn't that sweet?
|
|
172
174
|
|
|
173
175
|
|
|
174
176
|
# Return Value
|
|
175
177
|
|
|
176
|
-
`
|
|
178
|
+
`peek()` returns its argument(s), so `peek()` can easily be inserted into
|
|
177
179
|
pre-existing code.
|
|
178
180
|
|
|
179
181
|
```
|
|
180
|
-
|
|
182
|
+
import peek
|
|
181
183
|
def add2(i):
|
|
182
184
|
return i + 2
|
|
183
|
-
b =
|
|
184
|
-
|
|
185
|
+
b = peek(add2(1000))
|
|
186
|
+
peek(b)
|
|
185
187
|
```
|
|
186
188
|
prints
|
|
187
189
|
```
|
|
188
|
-
|
|
189
|
-
|
|
190
|
+
peek| add2(1000): 1002
|
|
191
|
+
peek| b: 1002
|
|
190
192
|
```
|
|
191
193
|
# Debug entry and exit of function calls
|
|
192
194
|
|
|
193
|
-
When you apply `
|
|
195
|
+
When you apply `peek()` as a decorator to a function or method, both the entry and exit can be tracked.
|
|
194
196
|
The (keyword) arguments passed will be shown and upon return, the return value.
|
|
195
197
|
|
|
196
198
|
```
|
|
197
|
-
|
|
198
|
-
@
|
|
199
|
-
def mul(x,
|
|
200
|
-
return x *
|
|
199
|
+
import peek
|
|
200
|
+
@peek()
|
|
201
|
+
def mul(x, peek):
|
|
202
|
+
return x * peek
|
|
201
203
|
|
|
202
204
|
print(mul(5, 7))
|
|
203
205
|
```
|
|
204
206
|
prints
|
|
205
207
|
```
|
|
206
|
-
|
|
207
|
-
|
|
208
|
+
peek| called mul(5, 7)
|
|
209
|
+
peek| returned 35 from mul(5, 7) in 0.000006 seconds
|
|
208
210
|
35
|
|
209
211
|
```
|
|
210
212
|
It is possible to suppress the print-out of either the enter or the exit information with
|
|
211
213
|
the show_enter and show_exit parameters, like:
|
|
212
214
|
|
|
213
215
|
```
|
|
214
|
-
|
|
215
|
-
@
|
|
216
|
-
def mul(x,
|
|
217
|
-
return x *
|
|
216
|
+
import peek
|
|
217
|
+
@peek(show_exit=False)
|
|
218
|
+
def mul(x, peek):
|
|
219
|
+
return x * peek
|
|
218
220
|
|
|
219
221
|
print(mul(5, 7))
|
|
220
222
|
```
|
|
221
223
|
prints
|
|
222
224
|
```
|
|
223
|
-
|
|
225
|
+
peek| called mul(5, 7)
|
|
224
226
|
35
|
|
225
227
|
```
|
|
226
|
-
Note that it is possible to use `
|
|
228
|
+
Note that it is possible to use `peek` as a decorator without the parentheses, like
|
|
227
229
|
```
|
|
228
|
-
@
|
|
230
|
+
@peek
|
|
229
231
|
def diode(x):
|
|
230
232
|
return 0 if x<0 else x
|
|
231
233
|
```
|
|
232
|
-
, but this might not work correctly when the def/class definition spawns more than one line. So, always use `
|
|
233
|
-
`
|
|
234
|
+
, but this might not work correctly when the def/class definition spawns more than one line. So, always use `peek()` or
|
|
235
|
+
`peek(<parameters>)` when used as a decorator.
|
|
234
236
|
|
|
235
|
-
# Benchmarking with
|
|
237
|
+
# Benchmarking with peek
|
|
236
238
|
|
|
237
|
-
If you decorate a function or method with
|
|
239
|
+
If you decorate a function or method with peek, you will be offered the duration between entry and exit (in seconds) as a bonus.
|
|
238
240
|
|
|
239
241
|
That opens the door to simple benchmarking, like:
|
|
240
242
|
```
|
|
241
|
-
|
|
243
|
+
import peek
|
|
242
244
|
import time
|
|
243
245
|
|
|
244
|
-
@
|
|
246
|
+
@peek(show_enter=False,show_line_number=True)
|
|
245
247
|
def do_sort(i):
|
|
246
248
|
n = 10 ** i
|
|
247
249
|
x = sorted(list(range(n)))
|
|
@@ -252,66 +254,67 @@ for i in range(8):
|
|
|
252
254
|
```
|
|
253
255
|
the ouput will show the effects of the population size on the sort speed:
|
|
254
256
|
```
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
257
|
+
peek| #5 ==> returned ' 1' from do_sort(0) in 0.000027 seconds
|
|
258
|
+
peek| #5 ==> returned ' 10' from do_sort(1) in 0.000060 seconds
|
|
259
|
+
peek| #5 ==> returned ' 100' from do_sort(2) in 0.000748 seconds
|
|
260
|
+
peek| #5 ==> returned ' 1000' from do_sort(3) in 0.001897 seconds
|
|
261
|
+
peek| #5 ==> returned ' 10000' from do_sort(4) in 0.002231 seconds
|
|
262
|
+
peek| #5 ==> returned ' 100000' from do_sort(5) in 0.024014 seconds
|
|
263
|
+
peek| #5 ==> returned ' 1000000' from do_sort(6) in 0.257504 seconds
|
|
264
|
+
peek| #5 ==> returned ' 10000000' from do_sort(7) in 1.553495 seconds
|
|
263
265
|
```
|
|
264
266
|
|
|
265
|
-
It is also possible to time any code by using
|
|
267
|
+
It is also possible to time any code by using peek as a context manager, e.g.
|
|
266
268
|
```
|
|
267
|
-
with
|
|
269
|
+
with peek():
|
|
268
270
|
time.sleep(1)
|
|
269
271
|
```
|
|
270
272
|
wil print something like
|
|
271
273
|
```
|
|
272
|
-
|
|
273
|
-
|
|
274
|
+
peek| enter
|
|
275
|
+
peek| exit in 1.000900 seconds
|
|
274
276
|
```
|
|
275
277
|
You can include parameters here as well:
|
|
276
278
|
```
|
|
277
|
-
with
|
|
279
|
+
with peek(show_context=True, show_time=True):
|
|
278
280
|
time.sleep(1)
|
|
279
281
|
```
|
|
280
282
|
will print somethink like:
|
|
281
283
|
```
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
peek| #8 @ 13:20:32.605903 ==> enter
|
|
285
|
+
peek| #8 @ 13:20:33.609519 ==> exit in 1.003358 seconds
|
|
284
286
|
```
|
|
285
287
|
|
|
286
288
|
Finally, to help with timing code, you can request the current delta with
|
|
287
289
|
```
|
|
288
|
-
|
|
290
|
+
peek().delta
|
|
289
291
|
```
|
|
290
292
|
or (re)set it with
|
|
291
293
|
```
|
|
292
|
-
|
|
294
|
+
peek().delta = 0
|
|
293
295
|
```
|
|
294
296
|
So, e.g. to time a section of code:
|
|
295
297
|
```
|
|
296
|
-
|
|
298
|
+
peek.delta = 0
|
|
297
299
|
time.sleep(1)
|
|
298
|
-
duration =
|
|
299
|
-
|
|
300
|
+
duration = peek.delta
|
|
301
|
+
peek(duration)
|
|
300
302
|
```
|
|
301
303
|
might print:
|
|
302
304
|
```
|
|
303
|
-
|
|
305
|
+
peek| duration: 1.0001721999999997
|
|
304
306
|
```
|
|
305
307
|
|
|
306
308
|
# Configuration
|
|
307
309
|
|
|
308
|
-
For the configuration, it is important to realize that `
|
|
310
|
+
For the configuration, it is important to realize that `peek` is an instance of the `peek.Peek` class, which has
|
|
309
311
|
a number of configuration attributes:
|
|
312
|
+
|
|
310
313
|
```
|
|
311
314
|
------------------------------------------------------
|
|
312
315
|
attribute alternative default
|
|
313
316
|
------------------------------------------------------
|
|
314
|
-
prefix p "
|
|
317
|
+
prefix p "peek| "
|
|
315
318
|
output o "stderr"
|
|
316
319
|
serialize pprint.pformat
|
|
317
320
|
show_line_number sln False
|
|
@@ -342,24 +345,24 @@ delta dl 0
|
|
|
342
345
|
```
|
|
343
346
|
It is perfectly ok to set/get any of these attributes directly, like
|
|
344
347
|
```
|
|
345
|
-
|
|
346
|
-
print(
|
|
348
|
+
peek.prefix = "==> "
|
|
349
|
+
print(peek.prefix)
|
|
347
350
|
```
|
|
348
351
|
|
|
349
|
-
But, it is also possible to apply configuration directly in the call to `
|
|
352
|
+
But, it is also possible to apply configuration directly in the call to `peek`:
|
|
350
353
|
So, it is possible to say
|
|
351
354
|
```
|
|
352
|
-
|
|
353
|
-
|
|
355
|
+
import peek
|
|
356
|
+
peek(12, prefix="==> ")
|
|
354
357
|
```
|
|
355
358
|
, which will print
|
|
356
359
|
```
|
|
357
360
|
==> 12
|
|
358
361
|
```
|
|
359
|
-
It is also possible to configure
|
|
362
|
+
It is also possible to configure peek permanently with the configure method.
|
|
360
363
|
```
|
|
361
|
-
|
|
362
|
-
|
|
364
|
+
peek.configure(prefix="==> ")
|
|
365
|
+
peek(12)
|
|
363
366
|
```
|
|
364
367
|
will print
|
|
365
368
|
```
|
|
@@ -367,21 +370,21 @@ will print
|
|
|
367
370
|
```
|
|
368
371
|
It is arguably easier to say:
|
|
369
372
|
```
|
|
370
|
-
|
|
371
|
-
|
|
373
|
+
peek.prefix = "==> "
|
|
374
|
+
peek(12)
|
|
372
375
|
```
|
|
373
376
|
or even
|
|
374
377
|
```
|
|
375
|
-
|
|
376
|
-
|
|
378
|
+
peek.p = "==> "
|
|
379
|
+
peek(12)
|
|
377
380
|
```
|
|
378
381
|
to print
|
|
379
382
|
```
|
|
380
383
|
==> 12
|
|
381
384
|
```
|
|
382
|
-
Yet another way to configure
|
|
385
|
+
Yet another way to configure peek is to get a new instance of peek with peek.new() and the required configuration:
|
|
383
386
|
```
|
|
384
|
-
z =
|
|
387
|
+
z = peek.new(prefix="==> ")
|
|
385
388
|
z(12)
|
|
386
389
|
```
|
|
387
390
|
will print
|
|
@@ -389,18 +392,18 @@ will print
|
|
|
389
392
|
==> 12
|
|
390
393
|
```
|
|
391
394
|
|
|
392
|
-
Or, yet another possibility is to clone
|
|
395
|
+
Or, yet another possibility is to clone peek (optionally with modified attributes):
|
|
393
396
|
```
|
|
394
|
-
yd1 =
|
|
395
|
-
yd2 =
|
|
397
|
+
yd1 = peek.clone(show_date=True)
|
|
398
|
+
yd2 = peek.clone()
|
|
396
399
|
yd2.configure(show_date=True)
|
|
397
400
|
```
|
|
398
401
|
After this `yd1` and `yd2` will behave similarly (but they are not the same!)
|
|
399
402
|
|
|
400
403
|
## prefix / p
|
|
401
404
|
```
|
|
402
|
-
|
|
403
|
-
|
|
405
|
+
import peek
|
|
406
|
+
peek('world', prefix='hello -> ')
|
|
404
407
|
```
|
|
405
408
|
prints
|
|
406
409
|
```
|
|
@@ -411,12 +414,12 @@ hello -> 'world'
|
|
|
411
414
|
|
|
412
415
|
```
|
|
413
416
|
import time
|
|
414
|
-
|
|
417
|
+
import peek
|
|
415
418
|
def unix_timestamp():
|
|
416
419
|
return f"{int(time.time())} "
|
|
417
420
|
hello = "world"
|
|
418
|
-
|
|
419
|
-
|
|
421
|
+
peek.configure(prefix=unix_timestamp)
|
|
422
|
+
peek(hello)
|
|
420
423
|
```
|
|
421
424
|
prints
|
|
422
425
|
```
|
|
@@ -434,35 +437,35 @@ The `output` attribute can be
|
|
|
434
437
|
|
|
435
438
|
In the example below,
|
|
436
439
|
```
|
|
437
|
-
|
|
440
|
+
import peek
|
|
438
441
|
import sys
|
|
439
|
-
|
|
440
|
-
|
|
442
|
+
peek(1, output=print)
|
|
443
|
+
peek(2, output=sys.stdout
|
|
441
444
|
with open("test", "a+") as f:
|
|
442
|
-
|
|
443
|
-
|
|
445
|
+
peek(3, output=f)
|
|
446
|
+
peek(4, output="")
|
|
444
447
|
```
|
|
445
|
-
* `
|
|
446
|
-
* `
|
|
447
|
-
* `
|
|
448
|
-
* `
|
|
448
|
+
* `peek| 1` will be printed to stdout
|
|
449
|
+
* `peek| 2` will be printed to stdout
|
|
450
|
+
* `peek| 3` will be appended to the file test
|
|
451
|
+
* `peek| 4` will *disappear*
|
|
449
452
|
|
|
450
|
-
As `output` may be any callable, you can even use this to automatically log any `
|
|
453
|
+
As `output` may be any callable, you can even use this to automatically log any `peek` output:
|
|
451
454
|
```
|
|
452
|
-
|
|
455
|
+
import peek
|
|
453
456
|
import logging
|
|
454
457
|
logging.basicConfig(level="INFO")
|
|
455
458
|
log = logging.getLogger("demo")
|
|
456
|
-
|
|
459
|
+
peek.configure(output=log.info)
|
|
457
460
|
a = {1, 2, 3, 4, 5}
|
|
458
|
-
|
|
461
|
+
peek(a)
|
|
459
462
|
a.remove(4)
|
|
460
|
-
|
|
463
|
+
peek(a)
|
|
461
464
|
```
|
|
462
465
|
will print to stderr:
|
|
463
466
|
```
|
|
464
|
-
INFO:demo:
|
|
465
|
-
INFO:demo:
|
|
467
|
+
INFO:demo:peek| a: {1, 2, 3, 4, 5}
|
|
468
|
+
INFO:demo:peek| a: {1, 2, 3, 5}
|
|
466
469
|
```
|
|
467
470
|
Finally, you can specify the following strings:
|
|
468
471
|
```
|
|
@@ -477,9 +480,9 @@ Finally, you can specify the following strings:
|
|
|
477
480
|
```
|
|
478
481
|
E.g.
|
|
479
482
|
```
|
|
480
|
-
|
|
483
|
+
import peek
|
|
481
484
|
import sys
|
|
482
|
-
|
|
485
|
+
peek.configure(output="stdout")
|
|
483
486
|
```
|
|
484
487
|
to print to stdout.
|
|
485
488
|
|
|
@@ -490,7 +493,7 @@ for example, to handle non-standard datatypes in a custom fashion.
|
|
|
490
493
|
The serialize function should accept at least one parameter.
|
|
491
494
|
The function can optionally accept the keyword arguments `width` and `sort_dicts`, `compact`, `indent`, `underscore_numbers` and `depth`.
|
|
492
495
|
```
|
|
493
|
-
|
|
496
|
+
import peek
|
|
494
497
|
def add_len(obj):
|
|
495
498
|
if hasattr(obj, "__len__"):
|
|
496
499
|
add = f" [len={len(obj)}]"
|
|
@@ -500,136 +503,136 @@ def add_len(obj):
|
|
|
500
503
|
|
|
501
504
|
l = list(range(7))
|
|
502
505
|
hello = "world"
|
|
503
|
-
|
|
506
|
+
peek(7, hello, l, serialize=add_len)
|
|
504
507
|
```
|
|
505
508
|
prints
|
|
506
509
|
```
|
|
507
|
-
|
|
510
|
+
peek| 7, hello: 'world' [len=5], l: [0, 1, 2, 3, 4, 5, 6] [len=7]
|
|
508
511
|
```
|
|
509
512
|
|
|
510
513
|
## show_line_number / sln
|
|
511
|
-
If True, adds the `
|
|
514
|
+
If True, adds the `peek()` call's line number and possible the filename and parent function to `peek()`'s output.
|
|
512
515
|
|
|
513
516
|
```
|
|
514
|
-
|
|
515
|
-
|
|
517
|
+
import peek
|
|
518
|
+
peek.configure(show_line_number=True)
|
|
516
519
|
def shout():
|
|
517
520
|
hello="world"
|
|
518
|
-
|
|
521
|
+
peek(hello)
|
|
519
522
|
shout()
|
|
520
523
|
```
|
|
521
524
|
prints something like
|
|
522
525
|
```
|
|
523
|
-
|
|
526
|
+
peek| #5 in shout() ==> hello: 'world'
|
|
524
527
|
```
|
|
525
528
|
|
|
526
529
|
If "no parent" or "n", the parent function will not be shown.
|
|
527
530
|
```
|
|
528
|
-
|
|
529
|
-
|
|
531
|
+
import peek
|
|
532
|
+
peek.configure(show_line_number="n")
|
|
530
533
|
def shout():
|
|
531
534
|
hello="world"
|
|
532
|
-
|
|
535
|
+
peek(hello)
|
|
533
536
|
shout()
|
|
534
537
|
```
|
|
535
538
|
prints something like
|
|
536
539
|
```
|
|
537
|
-
|
|
540
|
+
peek| #5 ==> hello: 'world'
|
|
538
541
|
```
|
|
539
|
-
Note that if you call `
|
|
542
|
+
Note that if you call `peek` without any arguments, the line number is always shown, regardless of the status `show_line_number`.
|
|
540
543
|
|
|
541
544
|
See below for an explanation of the information provided.
|
|
542
545
|
|
|
543
546
|
## show_time / st
|
|
544
|
-
If True, adds the current time to `
|
|
547
|
+
If True, adds the current time to `peek()`'s output.
|
|
545
548
|
|
|
546
549
|
```
|
|
547
|
-
|
|
548
|
-
|
|
550
|
+
import peek
|
|
551
|
+
peek.configure(show_time=True)
|
|
549
552
|
hello="world"
|
|
550
|
-
|
|
553
|
+
peek(hello)
|
|
551
554
|
```
|
|
552
555
|
prints something like
|
|
553
556
|
```
|
|
554
|
-
|
|
557
|
+
peek| @ 13:01:47.588125 ==> hello: 'world'
|
|
555
558
|
```
|
|
556
559
|
|
|
557
560
|
## show_delta / sd
|
|
558
|
-
If True, adds the number of seconds since the start of the program to `
|
|
561
|
+
If True, adds the number of seconds since the start of the program to `peek()`'s output.
|
|
559
562
|
```
|
|
560
|
-
|
|
563
|
+
import peek
|
|
561
564
|
import time
|
|
562
|
-
|
|
565
|
+
peek.configure(show_delta=True)
|
|
563
566
|
french = "bonjour le monde"
|
|
564
567
|
english = "hallo world"
|
|
565
|
-
|
|
568
|
+
peek(english)
|
|
566
569
|
time.sleep(1)
|
|
567
|
-
|
|
570
|
+
peek(french)
|
|
568
571
|
```
|
|
569
572
|
prints something like
|
|
570
573
|
```
|
|
571
|
-
|
|
572
|
-
|
|
574
|
+
peek| delta=0.088 ==> english: 'hallo world'
|
|
575
|
+
peek| delta=1.091 ==> french: 'bonjour le monde'
|
|
573
576
|
```
|
|
574
577
|
|
|
575
578
|
## show_enter / se
|
|
576
|
-
When used as a decorator or context manager, by default,
|
|
579
|
+
When used as a decorator or context manager, by default, peek ouputs a line when the decorated the
|
|
577
580
|
function is called or the context manager is entered.
|
|
578
581
|
|
|
579
582
|
With `show_enter=False` this line can be suppressed.
|
|
580
583
|
|
|
581
584
|
## show_exit / sx
|
|
582
|
-
When used as a decorator or context manager, by default,
|
|
585
|
+
When used as a decorator or context manager, by default, peek ouputs a line when the decorated the
|
|
583
586
|
function returned or the context manager is exited.
|
|
584
587
|
|
|
585
588
|
With `show_exit=False` this line can be suppressed.
|
|
586
589
|
|
|
587
590
|
|
|
588
591
|
## show_traceback / stb
|
|
589
|
-
When show_traceback is True, the ordinary output of
|
|
592
|
+
When show_traceback is True, the ordinary output of peek() will be followed by a printout of the
|
|
590
593
|
traceback, similar to an error traceback.
|
|
591
594
|
```
|
|
592
|
-
|
|
593
|
-
|
|
595
|
+
import peek
|
|
596
|
+
peek.show_traceback=True
|
|
594
597
|
def x():
|
|
595
|
-
|
|
598
|
+
peek()
|
|
596
599
|
|
|
597
600
|
x()
|
|
598
601
|
x()
|
|
599
602
|
```
|
|
600
603
|
prints
|
|
601
604
|
```
|
|
602
|
-
|
|
605
|
+
peek| #4 in x()
|
|
603
606
|
Traceback (most recent call last)
|
|
604
|
-
File "c:\Users\Ruud\Dropbox (Personal)\Apps\Python Ruud\
|
|
607
|
+
File "c:\Users\Ruud\Dropbox (Personal)\Apps\Python Ruud\peek\x.py", line 6, in <module>
|
|
605
608
|
x()
|
|
606
|
-
File "c:\Users\Ruud\Dropbox (Personal)\Apps\Python Ruud\
|
|
607
|
-
|
|
608
|
-
|
|
609
|
+
File "c:\Users\Ruud\Dropbox (Personal)\Apps\Python Ruud\peek\x.py", line 4, in x
|
|
610
|
+
peek()
|
|
611
|
+
peek| #4 in x()
|
|
609
612
|
Traceback (most recent call last)
|
|
610
|
-
File "c:\Users\Ruud\Dropbox (Personal)\Apps\Python Ruud\
|
|
613
|
+
File "c:\Users\Ruud\Dropbox (Personal)\Apps\Python Ruud\peek\x.py", line 7, in <module>
|
|
611
614
|
x()
|
|
612
|
-
File "c:\Users\Ruud\Dropbox (Personal)\Apps\Python Ruud\
|
|
613
|
-
|
|
615
|
+
File "c:\Users\Ruud\Dropbox (Personal)\Apps\Python Ruud\peek\x.py", line 4, in x
|
|
616
|
+
peek()
|
|
614
617
|
```
|
|
615
|
-
The `show_traceback` functionality is also available when
|
|
618
|
+
The `show_traceback` functionality is also available when peek is used as a decorator or context manager.
|
|
616
619
|
|
|
617
620
|
## line_length / ll
|
|
618
621
|
This attribute is used to specify the line length (for wrapping). The default is 80.
|
|
619
|
-
|
|
622
|
+
Peek always tries to keep all output on one line, but if it can't it will wrap:
|
|
620
623
|
```
|
|
621
624
|
d = dict(a1=1,a2=dict(a=1,b=1,c=3),a3=list(range(10)))
|
|
622
|
-
|
|
623
|
-
|
|
625
|
+
peek(d)
|
|
626
|
+
peek(d, line_length=120)
|
|
624
627
|
```
|
|
625
628
|
prints
|
|
626
629
|
```
|
|
627
|
-
|
|
630
|
+
peek|
|
|
628
631
|
d:
|
|
629
632
|
{'a1': 1,
|
|
630
633
|
'a2': {'a': 1, 'b': 1, 'c': 3},
|
|
631
634
|
'a3': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}
|
|
632
|
-
|
|
635
|
+
peek| d: {'a1': 1, 'a2': {'a': 1, 'b': 1, 'c': 3}, 'a3': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}
|
|
633
636
|
```
|
|
634
637
|
|
|
635
638
|
## compact / c
|
|
@@ -637,12 +640,12 @@ This attribute is used to specify the compact parameter for `pformat` (see the p
|
|
|
637
640
|
for details). `compact` is False by default.
|
|
638
641
|
```
|
|
639
642
|
a = 9 * ["0123456789"]
|
|
640
|
-
|
|
641
|
-
|
|
643
|
+
peek(a)
|
|
644
|
+
peek(a, compact=True)
|
|
642
645
|
```
|
|
643
646
|
prints
|
|
644
647
|
```
|
|
645
|
-
|
|
648
|
+
peek|
|
|
646
649
|
a:
|
|
647
650
|
['0123456789',
|
|
648
651
|
'0123456789',
|
|
@@ -653,7 +656,7 @@ y|
|
|
|
653
656
|
'0123456789',
|
|
654
657
|
'0123456789',
|
|
655
658
|
'0123456789']
|
|
656
|
-
|
|
659
|
+
peek|
|
|
657
660
|
a:
|
|
658
661
|
['0123456789', '0123456789', '0123456789', '0123456789', '0123456789',
|
|
659
662
|
'0123456789', '0123456789', '0123456789', '0123456789']
|
|
@@ -664,16 +667,16 @@ This attribute is used to specify the indent parameter for `pformat` (see the pp
|
|
|
664
667
|
for details). `indent` is 1 by default.
|
|
665
668
|
```
|
|
666
669
|
s = "01234567890012345678900123456789001234567890"
|
|
667
|
-
|
|
668
|
-
|
|
670
|
+
peek( [s, [s]])
|
|
671
|
+
peek( [s, [s]], indent=4)
|
|
669
672
|
```
|
|
670
673
|
prints
|
|
671
674
|
```
|
|
672
|
-
|
|
675
|
+
peek|
|
|
673
676
|
[s, [s]]:
|
|
674
677
|
['01234567890012345678900123456789001234567890',
|
|
675
678
|
['01234567890012345678900123456789001234567890']]
|
|
676
|
-
|
|
679
|
+
peek|
|
|
677
680
|
[s, [s]]:
|
|
678
681
|
[ '01234567890012345678900123456789001234567890',
|
|
679
682
|
['01234567890012345678900123456789001234567890']]
|
|
@@ -684,19 +687,19 @@ This attribute is used to specify the depth parameter for `pformat` (see the ppr
|
|
|
684
687
|
for details). `depth` is `1000000` by default.
|
|
685
688
|
```
|
|
686
689
|
s = "01234567890012345678900123456789001234567890"
|
|
687
|
-
|
|
688
|
-
|
|
690
|
+
peek([s,[s,[s,[s,s]]]])
|
|
691
|
+
peek([s,[s,[s,[s,s]]]], depth=3)
|
|
689
692
|
```
|
|
690
693
|
prints
|
|
691
694
|
```
|
|
692
|
-
|
|
695
|
+
peek|
|
|
693
696
|
[s,[s,[s,[s,s]]]]:
|
|
694
697
|
['01234567890012345678900123456789001234567890',
|
|
695
698
|
['01234567890012345678900123456789001234567890',
|
|
696
699
|
['01234567890012345678900123456789001234567890',
|
|
697
700
|
['01234567890012345678900123456789001234567890',
|
|
698
701
|
'01234567890012345678900123456789001234567890']]]]
|
|
699
|
-
|
|
702
|
+
peek|
|
|
700
703
|
[s,[s,[s,[s,s]]]]:
|
|
701
704
|
['01234567890012345678900123456789001234567890',
|
|
702
705
|
['01234567890012345678900123456789001234567890',
|
|
@@ -711,23 +714,23 @@ The default is 4 blanks.
|
|
|
711
714
|
E.g.
|
|
712
715
|
```
|
|
713
716
|
d = dict(a1=1,a2=dict(a=1,b=1,c=3),a3=list(range(10)))
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
+
peek(d, wrap_indent=" ")
|
|
718
|
+
peek(d, wrap_indent="....")
|
|
719
|
+
peek(d, wrap_indent=2)
|
|
717
720
|
```
|
|
718
721
|
prints
|
|
719
722
|
```
|
|
720
|
-
|
|
723
|
+
peek|
|
|
721
724
|
d:
|
|
722
725
|
{'a1': 1,
|
|
723
726
|
'a2': {'a': 1, 'b': 1, 'c': 3},
|
|
724
727
|
'a3': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}
|
|
725
|
-
|
|
728
|
+
peek|
|
|
726
729
|
....d:
|
|
727
730
|
........{'a1': 1,
|
|
728
731
|
........ 'a2': {'a': 1, 'b': 1, 'c': 3},
|
|
729
732
|
........ 'a3': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]}
|
|
730
|
-
|
|
733
|
+
peek|
|
|
731
734
|
d:
|
|
732
735
|
{'a1': 1,
|
|
733
736
|
'a2': {'a': 1, 'b': 1, 'c': 3},
|
|
@@ -737,52 +740,52 @@ y|
|
|
|
737
740
|
## enabled / e
|
|
738
741
|
Can be used to disable the output:
|
|
739
742
|
```
|
|
740
|
-
|
|
743
|
+
import peek
|
|
741
744
|
|
|
742
|
-
|
|
745
|
+
peek.configure(enabled=False)
|
|
743
746
|
s = 'the world is '
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
+
peek(s + 'perfect.')
|
|
748
|
+
peek.configure(enabled=True)
|
|
749
|
+
peek(s + 'on fire.')
|
|
747
750
|
```
|
|
748
751
|
prints
|
|
749
752
|
```
|
|
750
|
-
|
|
753
|
+
peek| s + 'on fire.': 'the world is on fire.'
|
|
751
754
|
```
|
|
752
755
|
and nothing about a perfect world.
|
|
753
756
|
|
|
754
757
|
## sort_dicts / sdi
|
|
755
|
-
By default,
|
|
758
|
+
By default, peek does not sort dicts (printed by pprint). However, it is possible to get the
|
|
756
759
|
default pprint behaviour (i.e. sorting dicts) with the sorted_dicts attribute:
|
|
757
760
|
|
|
758
761
|
```
|
|
759
762
|
world = {"EN": "world", "NL": "wereld", "FR": "monde", "DE": "Welt"}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
+
peek(world))
|
|
764
|
+
peek(world, sort_dicts=False)
|
|
765
|
+
peek(world, sort_dicts=True)
|
|
763
766
|
```
|
|
764
767
|
prints
|
|
765
768
|
```
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
+
peek| world: {'EN': 'world', 'NL': 'wereld', 'FR': 'monde', 'DE': 'Welt'}
|
|
770
|
+
peek| world: {'EN': 'world', 'NL': 'wereld', 'FR': 'monde', 'DE': 'Welt'}
|
|
771
|
+
peek| world: {'DE': 'Welt', 'EN': 'world', 'FR': 'monde', 'NL': 'wereld'}
|
|
769
772
|
```
|
|
770
773
|
|
|
771
774
|
## underscore_numbers / un
|
|
772
|
-
By default,
|
|
775
|
+
By default, peek does not add underscores in big numberss (printed by pprint). However, it is possible to get the
|
|
773
776
|
default pprint behaviour with the underscore_numbers attribute:
|
|
774
777
|
|
|
775
778
|
```
|
|
776
779
|
numbers = dict(one= 1, thousand= 1000, million=1000000, x1234567890= 1234567890)
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
+
peek(numbers)
|
|
781
|
+
peek(numbers, underscore_numbers=True)
|
|
782
|
+
peek(numbers, un=False)
|
|
780
783
|
```
|
|
781
784
|
prints
|
|
782
785
|
```
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
+
peek| numbers: {'one': 1, 'thousand': 1000, 'million': 1000000, 'x1234567890': 1234567890}
|
|
787
|
+
peek| numbers: {'one': 1, 'thousand': 1_000, 'million': 1_000_000, 'x1234567890': 1_234_567_890}
|
|
788
|
+
peek| numbers: {'one': 1, 'thousand': 1000, 'million': 1000000, 'x1234567890': 1234567890}
|
|
786
789
|
```
|
|
787
790
|
|
|
788
791
|
## separator / sep
|
|
@@ -792,40 +795,40 @@ It is possible to change this with the attribute ` separator`:
|
|
|
792
795
|
a="abcd"
|
|
793
796
|
b=1
|
|
794
797
|
c=1000
|
|
795
|
-
d=list("
|
|
796
|
-
|
|
797
|
-
|
|
798
|
+
d=list("peek")
|
|
799
|
+
peek(a,(b,c),d)
|
|
800
|
+
peek(a,(b,c),d, separator=" | ")
|
|
798
801
|
```
|
|
799
802
|
prints
|
|
800
803
|
```
|
|
801
|
-
|
|
802
|
-
|
|
804
|
+
peek| a: 'abcd', (b,c): (1, 1000), d: ['peek', 'c', 'e', 'c', 'r', 'e', 'a', 'm']
|
|
805
|
+
peek| a: 'abcd' | (b,c): (1, 1000) | d: ['peek', 'c', 'e', 'c', 'r', 'e', 'a', 'm']
|
|
803
806
|
```
|
|
804
807
|
## context_separator / cs
|
|
805
808
|
By default the line_number, time and/or delta are followed by ` ==> `.
|
|
806
809
|
It is possible to change this with the attribute `context_separator`:
|
|
807
810
|
```
|
|
808
811
|
a="abcd"
|
|
809
|
-
|
|
810
|
-
|
|
812
|
+
peek(a)
|
|
813
|
+
peek(a, show_time=True, context_separator = ' \u279c ')
|
|
811
814
|
```
|
|
812
815
|
prints:
|
|
813
816
|
```
|
|
814
|
-
|
|
815
|
-
|
|
817
|
+
peek| @ 12:56:11.341650 ==> a: 'abcd'
|
|
818
|
+
peek| @ 12:56:11.485567 ➜ a: 'abcd'
|
|
816
819
|
```
|
|
817
820
|
## equals_separator / es
|
|
818
821
|
By default name of a variable and its value are separated by `: `.
|
|
819
822
|
It is possible to change this with the attribute `equals_separator`:
|
|
820
823
|
```
|
|
821
824
|
a="abcd"
|
|
822
|
-
|
|
823
|
-
|
|
825
|
+
peek(a)
|
|
826
|
+
peek(a, equals_separator = ' == ")
|
|
824
827
|
```
|
|
825
828
|
prints:
|
|
826
829
|
```
|
|
827
|
-
|
|
828
|
-
|
|
830
|
+
peek| a: 'abcd'
|
|
831
|
+
peek| a == 'abcd'
|
|
829
832
|
```
|
|
830
833
|
|
|
831
834
|
## values_only / vo
|
|
@@ -833,15 +836,15 @@ If False (the default), both the left-hand side (if possible) and the
|
|
|
833
836
|
value will be printed. If True, the left_hand side will be suppressed:
|
|
834
837
|
```
|
|
835
838
|
hello = "world"
|
|
836
|
-
|
|
837
|
-
|
|
839
|
+
peek(hello, 2 * hello)
|
|
840
|
+
peek(hello, 2 * hello, values_only=True)
|
|
838
841
|
```
|
|
839
842
|
prints
|
|
840
843
|
```
|
|
841
|
-
|
|
842
|
-
|
|
844
|
+
peek| hello: 'world', 2 * hello = 'worldworld'
|
|
845
|
+
peek| 'world', 'worldworld'
|
|
843
846
|
```
|
|
844
|
-
The values=True version of
|
|
847
|
+
The values=True version of peek can be seen as a supercharged print/pprint.
|
|
845
848
|
|
|
846
849
|
|
|
847
850
|
## values_only_for_fstrings / voff
|
|
@@ -850,32 +853,32 @@ value will be printed for f-strings.
|
|
|
850
853
|
If True, the left_hand side will be suppressed in case of an f-string:
|
|
851
854
|
```
|
|
852
855
|
x = 12.3
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
+
peek(f"{x:0.3e}")
|
|
857
|
+
peek.values_only_for_fstrings = True
|
|
858
|
+
peek(f"{x:0.3e}")
|
|
856
859
|
```
|
|
857
860
|
prints
|
|
858
861
|
```
|
|
859
|
-
|
|
860
|
-
|
|
862
|
+
peek| f"{x:0.3e}": '1.230e+01'
|
|
863
|
+
peek| '1.230e+01'
|
|
861
864
|
```
|
|
862
865
|
Note that if `values_only` is True, f-string will be suppressed, regardless of `values_only_for_fstrings`.
|
|
863
866
|
|
|
864
867
|
## return_none / rn
|
|
865
|
-
Normally, `
|
|
866
|
-
or REPL, that value will be shown, and that can be annoying. Therefore, if `return_none`is True, `
|
|
868
|
+
Normally, `peek()`returns the values passed directly, which is usually fine. However, when used in a notebook
|
|
869
|
+
or REPL, that value will be shown, and that can be annoying. Therefore, if `return_none`is True, `peek()`will
|
|
867
870
|
return None and thus not show anything.
|
|
868
871
|
```
|
|
869
872
|
a = 3
|
|
870
|
-
print(
|
|
871
|
-
|
|
872
|
-
print(
|
|
873
|
+
print(peek(a, a + 1))
|
|
874
|
+
peek.configure(return_none=True)
|
|
875
|
+
print(peek(a, a + 1))
|
|
873
876
|
```
|
|
874
877
|
prints
|
|
875
878
|
```
|
|
876
|
-
|
|
879
|
+
peek| (3, 4)
|
|
877
880
|
(3, 4)
|
|
878
|
-
|
|
881
|
+
peek| (3, 4)
|
|
879
882
|
None
|
|
880
883
|
```
|
|
881
884
|
|
|
@@ -886,40 +889,40 @@ line_length, even those that are not truncated by pformat.
|
|
|
886
889
|
## delta / dl
|
|
887
890
|
The delta attribute can be used to (re)set the current delta, e.g.
|
|
888
891
|
```
|
|
889
|
-
|
|
890
|
-
print(
|
|
892
|
+
peek.configure(dl=0)
|
|
893
|
+
print(peek.delta)
|
|
891
894
|
```
|
|
892
895
|
prints a value that slightly more than 0.
|
|
893
896
|
|
|
894
897
|
|
|
895
898
|
## decorator / d
|
|
896
|
-
Normally, an
|
|
899
|
+
Normally, an peek instance can be used as to show values, as a decorator and as a
|
|
897
900
|
context manager.
|
|
898
901
|
|
|
899
902
|
However, when used from a REPL the usage as a decorator can't be detected properly and in that case,
|
|
900
903
|
specify `decorator=True`. E.g.
|
|
901
904
|
```
|
|
902
|
-
>>>@
|
|
905
|
+
>>>@peek(decorator=True)
|
|
903
906
|
>>>def add2(x):
|
|
904
907
|
>>> return x + 2
|
|
905
908
|
>>>print(add2(10))
|
|
906
|
-
|
|
907
|
-
|
|
909
|
+
peek| called add2(10)
|
|
910
|
+
peek| returned 12 from add2(10) in 0.000548 seconds
|
|
908
911
|
12
|
|
909
912
|
```
|
|
910
913
|
|
|
911
|
-
The `decorator` attribute is also required when using `
|
|
914
|
+
The `decorator` attribute is also required when using `peek()` as a decorator
|
|
912
915
|
witb *fast disabling* (see below).
|
|
913
916
|
```
|
|
914
|
-
|
|
915
|
-
@
|
|
917
|
+
peek.enabled([])
|
|
918
|
+
@peek()
|
|
916
919
|
def add2(x):
|
|
917
920
|
return x + 2
|
|
918
921
|
```
|
|
919
922
|
would fail with`TypeError: 'NoneType' object is not callable`, but
|
|
920
923
|
```
|
|
921
|
-
|
|
922
|
-
@
|
|
924
|
+
peek.enabled([])
|
|
925
|
+
@peek(decorator=True)
|
|
923
926
|
def add2(x):
|
|
924
927
|
return x + 2
|
|
925
928
|
```
|
|
@@ -927,29 +930,29 @@ will run correctly.
|
|
|
927
930
|
|
|
928
931
|
|
|
929
932
|
## context_manager / cm
|
|
930
|
-
Normally, an
|
|
933
|
+
Normally, an peek instance can be used as to show values, as a decorator and as a
|
|
931
934
|
context manager.
|
|
932
935
|
|
|
933
936
|
However, when used from a REPL the usage as a context manager can't be detected properly and in that case,
|
|
934
937
|
specify `context_manager=True`. E.g.
|
|
935
938
|
```
|
|
936
|
-
>>>with
|
|
939
|
+
>>>with peek(context_manager=True)
|
|
937
940
|
>>> pass
|
|
938
|
-
|
|
939
|
-
|
|
941
|
+
peek| enter
|
|
942
|
+
peek| exit in 0.008644 seconds
|
|
940
943
|
```
|
|
941
944
|
|
|
942
|
-
The `context_manager` attribute is also required when using `
|
|
945
|
+
The `context_manager` attribute is also required when using `peek():` as a context manager
|
|
943
946
|
with *fast disabling* (see below).
|
|
944
947
|
```
|
|
945
|
-
|
|
946
|
-
with
|
|
948
|
+
peek.enabled([])
|
|
949
|
+
with peek:
|
|
947
950
|
pass
|
|
948
951
|
```
|
|
949
952
|
would fail with `AttributeError: __enter__`, but
|
|
950
953
|
```
|
|
951
|
-
|
|
952
|
-
with
|
|
954
|
+
peek.enabled([])
|
|
955
|
+
with peek(context_manager=True):
|
|
953
956
|
pass
|
|
954
957
|
```
|
|
955
958
|
will run correctly.
|
|
@@ -960,8 +963,8 @@ If provided is True, output will be generated as usual (obeying the enabled attr
|
|
|
960
963
|
|
|
961
964
|
```
|
|
962
965
|
x = 1
|
|
963
|
-
|
|
964
|
-
|
|
966
|
+
peek("should print", provided=x > 0)
|
|
967
|
+
peek("should not print", provided=x < 0)
|
|
965
968
|
```
|
|
966
969
|
This will print
|
|
967
970
|
```
|
|
@@ -970,106 +973,106 @@ should print
|
|
|
970
973
|
|
|
971
974
|
# Return a string instead of sending to output
|
|
972
975
|
|
|
973
|
-
`
|
|
976
|
+
`peek(*args, as_str=True)` is like `peek(*args)` but the output is returned as a string instead
|
|
974
977
|
of written to output.
|
|
975
978
|
|
|
976
979
|
```
|
|
977
|
-
|
|
980
|
+
import peek
|
|
978
981
|
hello = "world"
|
|
979
|
-
s =
|
|
982
|
+
s = peek(hello, as_str=True)
|
|
980
983
|
print(s, end="")
|
|
981
984
|
```
|
|
982
985
|
prints
|
|
983
986
|
```
|
|
984
|
-
|
|
987
|
+
peek| hello: 'world'
|
|
985
988
|
```
|
|
986
989
|
|
|
987
990
|
Note that if enabled=False, the call will return the null string (`""`).
|
|
988
991
|
|
|
989
|
-
# Disabling
|
|
992
|
+
# Disabling peek's output
|
|
990
993
|
|
|
991
994
|
```
|
|
992
|
-
|
|
993
|
-
yd =
|
|
994
|
-
|
|
995
|
+
import peek
|
|
996
|
+
yd = peek.fork(show_delta=True)
|
|
997
|
+
peek(1)
|
|
995
998
|
yd(2)
|
|
996
|
-
|
|
997
|
-
|
|
999
|
+
peek.enabled = False
|
|
1000
|
+
peek(3)
|
|
998
1001
|
yd(4)
|
|
999
|
-
|
|
1000
|
-
|
|
1002
|
+
peek.enabled = True
|
|
1003
|
+
peek(5)
|
|
1001
1004
|
yd(6)
|
|
1002
|
-
print(
|
|
1005
|
+
print(peek.enabled)
|
|
1003
1006
|
```
|
|
1004
1007
|
prints
|
|
1005
1008
|
```
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1009
|
+
peek| 1
|
|
1010
|
+
peek| delta=0.011826 ==> 2
|
|
1011
|
+
peek| 5
|
|
1012
|
+
peek| delta=0.044893 ==> 6
|
|
1010
1013
|
True
|
|
1011
1014
|
```
|
|
1012
|
-
Of course `
|
|
1015
|
+
Of course `peek()` continues to return its arguments when disabled, of course.
|
|
1013
1016
|
|
|
1014
1017
|
It is also possible to suppress output with the provided attribute (see above).
|
|
1015
1018
|
|
|
1016
|
-
## Speeding up disabled
|
|
1017
|
-
When output is disabled, either via `
|
|
1018
|
-
|
|
1019
|
+
## Speeding up disabled peek
|
|
1020
|
+
When output is disabled, either via `peek.configure(enbabled=False)` or `peek.enable = False`,
|
|
1021
|
+
peek still has to check for usage as a decorator or context manager, which can be rather time
|
|
1019
1022
|
consuming.
|
|
1020
1023
|
|
|
1021
|
-
In order to speed up a program with disabled
|
|
1022
|
-
`
|
|
1023
|
-
the given arguments. If
|
|
1024
|
-
context manager will raise a runtime error, though. The `@
|
|
1024
|
+
In order to speed up a program with disabled peek calls, it is possible to specify
|
|
1025
|
+
`peek.configure(enabled=[])`, in which case `peek` will always just return
|
|
1026
|
+
the given arguments. If peek is disabled this way, usage as a `@peek()` decorator or as a `with peek():`
|
|
1027
|
+
context manager will raise a runtime error, though. The `@peek` decorator without parentheses will
|
|
1025
1028
|
not raise any exception, though.
|
|
1026
1029
|
|
|
1027
|
-
To use `
|
|
1030
|
+
To use `peek` as a decorator and still have *fast disabling*:
|
|
1028
1031
|
```
|
|
1029
|
-
|
|
1030
|
-
@
|
|
1032
|
+
peek.configure(enabled=[])
|
|
1033
|
+
@peek(decorator=True):
|
|
1031
1034
|
def add2(x):
|
|
1032
1035
|
return x + 2
|
|
1033
1036
|
x34 = add2(30)
|
|
1034
1037
|
```
|
|
1035
|
-
And, similarly, to use `
|
|
1038
|
+
And, similarly, to use `peek` as a context manager combined with *fast disabling*:
|
|
1036
1039
|
```
|
|
1037
|
-
|
|
1038
|
-
with @
|
|
1040
|
+
peek.configure(enabled=[])
|
|
1041
|
+
with @peek(context_manager=True):
|
|
1039
1042
|
pass
|
|
1040
1043
|
```
|
|
1041
1044
|
|
|
1042
1045
|
The table below shows it all.
|
|
1043
1046
|
```
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
execution speed
|
|
1048
|
-
|
|
1049
|
-
@
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
@
|
|
1053
|
-
with
|
|
1054
|
-
|
|
1055
|
-
|
|
1047
|
+
----------------------------------------------------------------------------------
|
|
1048
|
+
enabled=True enabled=False enabled=[]
|
|
1049
|
+
----------------------------------------------------------------------------------
|
|
1050
|
+
execution speed normal normal fast
|
|
1051
|
+
peek() normal no output no output
|
|
1052
|
+
@peek normal no output no output
|
|
1053
|
+
peek(decorator=True) normal no output no output
|
|
1054
|
+
peek(context_manager=True) normal no output no output
|
|
1055
|
+
@peek() normal no output TypeError
|
|
1056
|
+
with peek(): normal no output AttributeError/TypeError
|
|
1057
|
+
peek(as_str=True) normal "" ""
|
|
1058
|
+
----------------------------------------------------------------------------------
|
|
1056
1059
|
```
|
|
1057
1060
|
|
|
1058
|
-
# Using
|
|
1061
|
+
# Using peek as a substitute for `assert`
|
|
1059
1062
|
|
|
1060
|
-
|
|
1063
|
+
Peek has a method `assert_` that works like `assert`, but can be enabled or disabled with the enabled flag.
|
|
1061
1064
|
|
|
1062
1065
|
```
|
|
1063
1066
|
temperature = -1
|
|
1064
|
-
|
|
1067
|
+
peek.assert_(temperature > 0)
|
|
1065
1068
|
```
|
|
1066
1069
|
This will raise an AttributeError.
|
|
1067
1070
|
|
|
1068
1071
|
But
|
|
1069
1072
|
```
|
|
1070
|
-
|
|
1073
|
+
peek.enabled = False
|
|
1071
1074
|
temperature = -1
|
|
1072
|
-
|
|
1075
|
+
peek.assert_(temperature > 0)
|
|
1073
1076
|
```
|
|
1074
1077
|
will not.
|
|
1075
1078
|
|
|
@@ -1077,25 +1080,25 @@ Note that with the attribute propagation method, you can in effect have a layere
|
|
|
1077
1080
|
|
|
1078
1081
|
# Interpreting the line number information
|
|
1079
1082
|
|
|
1080
|
-
When `show_line_number` is True or
|
|
1083
|
+
When `show_line_number` is True or peek() is used without any parameters, the output will contain the line number like:
|
|
1081
1084
|
```
|
|
1082
|
-
|
|
1085
|
+
peek| #3 ==> a: 'abcd'
|
|
1083
1086
|
```
|
|
1084
1087
|
If the line resides in another file than the main file, the filename (without the path) will be shown as well:
|
|
1085
1088
|
```
|
|
1086
|
-
|
|
1089
|
+
peek| #30[foo.py] ==> foo: 'Foo'
|
|
1087
1090
|
```
|
|
1088
1091
|
And finally when used in a function or method, that function/method will be shown as well:
|
|
1089
1092
|
```
|
|
1090
|
-
|
|
1093
|
+
peek| #456[foo.py] in square_root ==> x: 123
|
|
1091
1094
|
```
|
|
1092
1095
|
The parent function can be suppressed by setting `show_line_number` or `sln` to `"n"` or `"no parent"`.
|
|
1093
1096
|
|
|
1094
1097
|
# Configuring at import time
|
|
1095
1098
|
|
|
1096
|
-
It can be useful to configure
|
|
1099
|
+
It can be useful to configure peek at import time. This can be done by providing a `peek.json` file which
|
|
1097
1100
|
can contain any attribute configuration overriding the standard settings.
|
|
1098
|
-
E.g. if there is an `
|
|
1101
|
+
E.g. if there is an `peek.json` file with the following contents
|
|
1099
1102
|
```
|
|
1100
1103
|
{
|
|
1101
1104
|
"o": "stdout",
|
|
@@ -1106,16 +1109,16 @@ E.g. if there is an `ycecream.json` file with the following contents
|
|
|
1106
1109
|
```
|
|
1107
1110
|
in the same folder as the application, this program:
|
|
1108
1111
|
```
|
|
1109
|
-
|
|
1112
|
+
import peek
|
|
1110
1113
|
hello = "world"
|
|
1111
|
-
|
|
1114
|
+
peek(hello)
|
|
1112
1115
|
```
|
|
1113
1116
|
will print to stdout (rather than stderr):
|
|
1114
1117
|
```
|
|
1115
|
-
|
|
1118
|
+
peek| @ 14:53:41.392190 ==> hello: 'world'
|
|
1116
1119
|
```
|
|
1117
|
-
At import time the sys.path will be searched for, in that order, to find an `
|
|
1118
|
-
you can place an `
|
|
1120
|
+
At import time the sys.path will be searched for, in that order, to find an `peek.json` file and use that. This mean that
|
|
1121
|
+
you can place an `peek.json` file in the site-packages folder where `peek` is installed to always use
|
|
1119
1122
|
these modified settings.
|
|
1120
1123
|
|
|
1121
1124
|
Please observe that json values are slightly different from their Python equivalents:
|
|
@@ -1131,177 +1134,186 @@ strings always double quoted
|
|
|
1131
1134
|
```
|
|
1132
1135
|
Note that not-specified attributes will remain the default settings.
|
|
1133
1136
|
|
|
1134
|
-
For obvious reasons, it is not possible to specify `serialize` in an
|
|
1137
|
+
For obvious reasons, it is not possible to specify `serialize` in an peek.json file.
|
|
1135
1138
|
|
|
1136
|
-
# Working with multiple instances of
|
|
1139
|
+
# Working with multiple instances of peek
|
|
1137
1140
|
|
|
1138
|
-
Normally, only the `
|
|
1141
|
+
Normally, only the `peek()` object is used.
|
|
1139
1142
|
|
|
1140
1143
|
It can be useful to have multiple instances, e.g. when some of the debugging has to be done with context information
|
|
1141
1144
|
and others requires an alternative prefix.
|
|
1142
1145
|
|
|
1143
|
-
THere are several ways to obtain a new instance of
|
|
1146
|
+
THere are several ways to obtain a new instance of peek:
|
|
1144
1147
|
|
|
1145
|
-
* by using `
|
|
1148
|
+
* by using `peek.new()`
|
|
1146
1149
|
|
|
1147
|
-
With this a new
|
|
1148
|
-
and possibly
|
|
1149
|
-
* by using `
|
|
1150
|
+
With this a new peek object is created with the default attributes
|
|
1151
|
+
and possibly peek.json overrides.
|
|
1152
|
+
* by using `peek.new(ignore_json=True)`
|
|
1150
1153
|
|
|
1151
|
-
With this a new
|
|
1152
|
-
* by using `
|
|
1154
|
+
With this a new peekobject is created with the default attibutes. Any peek.json files asre ignored.
|
|
1155
|
+
* by using `peek.fork()`
|
|
1153
1156
|
|
|
1154
|
-
With this a new
|
|
1155
|
-
* by using `
|
|
1157
|
+
With this a new peek object is created with the same attributes as the object it is created ('the parent') from. Note that any non set attributes are copied (propagated) from the parent.
|
|
1158
|
+
* by using `peek.clone()`, which copies all attributes from peek()
|
|
1156
1159
|
|
|
1157
|
-
With this a new
|
|
1160
|
+
With this a new peek object is created with the same attributes as the object it is created ('the parent') from. Note that the attributes are not propagated from the parent, in this case.
|
|
1158
1161
|
|
|
1159
|
-
* with `
|
|
1162
|
+
* with `peek()` used as a context manager
|
|
1160
1163
|
|
|
1161
1164
|
In either case, attributes can be added to override the default ones.
|
|
1162
1165
|
|
|
1163
1166
|
### Example
|
|
1164
1167
|
```
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1168
|
+
import peek
|
|
1169
|
+
peek_with_line_number = peek.fork(show_line_number=True)
|
|
1170
|
+
peek_with_new_prefix = peek.new(prefix="==> ")
|
|
1171
|
+
peek_with_new_prefix_and_time = peek_with_new_prefix.clone(show_time=True)
|
|
1169
1172
|
hello="world"
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
with
|
|
1178
|
-
|
|
1179
|
-
|
|
1173
|
+
peek_with_line_number(hello)
|
|
1174
|
+
peek_with_new_prefix(hello)
|
|
1175
|
+
peek_with_new_prefix_and_time(hello)
|
|
1176
|
+
peek.equals_separator = " == " # this affects only the forked objects
|
|
1177
|
+
peek_with_line_number(hello)
|
|
1178
|
+
peek_with_new_prefix(hello)
|
|
1179
|
+
peek_with_new_prefix_and_time(hello)
|
|
1180
|
+
with peek(prefix="peek_cm ") as peek_cm:
|
|
1181
|
+
peek_cm(hello)
|
|
1182
|
+
peek(hello)
|
|
1180
1183
|
```
|
|
1181
|
-
prints
|
|
1184
|
+
prints something like
|
|
1182
1185
|
```
|
|
1183
|
-
|
|
1186
|
+
peek| #19 ==> hello: 'world'
|
|
1184
1187
|
==> hello: 'world'
|
|
1185
|
-
==> @
|
|
1186
|
-
|
|
1188
|
+
==> @ 15:57:36.836442 ==> hello: 'world'
|
|
1189
|
+
peek| #23 ==> hello: 'world'
|
|
1187
1190
|
==> hello: 'world'
|
|
1188
|
-
==> @
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1191
|
+
==> @ 15:57:36.840495 ==> hello: 'world'
|
|
1192
|
+
peek_cm enter
|
|
1193
|
+
peek_cm hello: 'world'
|
|
1194
|
+
peek| hello: 'world'
|
|
1195
|
+
peek_cm exit in 0.002547 seconds
|
|
1193
1196
|
```
|
|
1194
1197
|
|
|
1195
1198
|
## ignore_json
|
|
1196
|
-
With `
|
|
1199
|
+
With `peek.new(ignore_json=True)` an instance of peek without having applied any json configuration file will be returned. That can be useful when guaranteeing the same output in several setups.
|
|
1197
1200
|
|
|
1198
1201
|
### Example
|
|
1199
|
-
Suppose we have an `
|
|
1202
|
+
Suppose we have an `peek.json` file in the current directory with the contents
|
|
1200
1203
|
```
|
|
1201
1204
|
{prefix="==>"}
|
|
1202
1205
|
```
|
|
1203
1206
|
Then
|
|
1204
1207
|
```
|
|
1205
|
-
|
|
1206
|
-
|
|
1208
|
+
peek_post_json = peek.new()
|
|
1209
|
+
peek_ignore_json = peek.new(ignore_json=True)
|
|
1207
1210
|
hello = "world"
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
+
peek(hello)
|
|
1212
|
+
peek_post_json(hello)
|
|
1213
|
+
peek_ignore_json(hello)
|
|
1211
1214
|
```
|
|
1212
1215
|
prints
|
|
1213
1216
|
```
|
|
1214
1217
|
==>hello: 'world'
|
|
1215
1218
|
==>hello: 'world'
|
|
1216
|
-
|
|
1219
|
+
peek| hello: 'world'
|
|
1217
1220
|
```
|
|
1218
1221
|
|
|
1219
1222
|
# Test script
|
|
1220
1223
|
|
|
1221
|
-
On GitHub is a file `
|
|
1222
|
-
of
|
|
1224
|
+
On GitHub is a file `test_peek.py` that tests (and thus also demonstrates) most of the functionality
|
|
1225
|
+
of peek.
|
|
1223
1226
|
|
|
1224
1227
|
It is very useful to have a look at the tests to see the features (some may be not covered (yet) in this readme).
|
|
1225
1228
|
|
|
1226
|
-
# Using
|
|
1229
|
+
# Using peek in a REPL
|
|
1227
1230
|
|
|
1228
|
-
|
|
1231
|
+
Peek may be used in a REPL, but with limited functionality:
|
|
1229
1232
|
* all arguments are just presented as such, i.e. no left-hand side, e.g.
|
|
1230
1233
|
```
|
|
1231
1234
|
>> hello = "world"
|
|
1232
|
-
>>>
|
|
1233
|
-
|
|
1235
|
+
>>> peek(hello, hello * 2)
|
|
1236
|
+
peek| 'hello', 'hellohello'
|
|
1234
1237
|
('hello', 'hellohello')
|
|
1235
1238
|
```
|
|
1236
1239
|
* line numbers are never shown
|
|
1237
|
-
* use as a decorator is only supported when you used as `
|
|
1238
|
-
* use as a context manager is only supported when used as `
|
|
1240
|
+
* use as a decorator is only supported when you used as `peek(decorator=True)` or `peek(d=1)`
|
|
1241
|
+
* use as a context manager is only supported when used as `peek(context_manager=True)`or `peek(cm=1)`
|
|
1239
1242
|
|
|
1240
|
-
# Alternative to `
|
|
1243
|
+
# Alternative to `peek`
|
|
1241
1244
|
|
|
1242
|
-
Sometimes,
|
|
1243
|
-
dealing with coordinates x, y and z.
|
|
1245
|
+
Sometimes, even peek is too long during a debug session is not suitable to use the name peek.
|
|
1244
1246
|
|
|
1245
|
-
In that case, it is possible to use
|
|
1247
|
+
In that case, it is possible to use p instead
|
|
1246
1248
|
```
|
|
1247
|
-
from
|
|
1249
|
+
from peek import p
|
|
1248
1250
|
```
|
|
1249
|
-
The `
|
|
1250
|
-
|
|
1251
|
+
The `p` object is a *fork* of peek with the prefix `"p| "`. That means that attributes of `peek` are propagated to `p`, unless overridden.
|
|
1252
|
+
p
|
|
1251
1253
|
Of course, it is also possible to use
|
|
1252
1254
|
```
|
|
1253
|
-
|
|
1255
|
+
import peek
|
|
1254
1256
|
```
|
|
1255
1257
|
or
|
|
1256
1258
|
```
|
|
1257
|
-
|
|
1259
|
+
pe = peek.new()
|
|
1258
1260
|
```
|
|
1259
1261
|
or
|
|
1260
1262
|
```
|
|
1261
|
-
yy =
|
|
1263
|
+
yy = peek.new(prefix="pe| ")
|
|
1262
1264
|
```
|
|
1263
1265
|
|
|
1264
1266
|
# Alternative installation
|
|
1265
1267
|
|
|
1266
|
-
With `install
|
|
1268
|
+
With `install peek from github.py`, you can install the peek.py directly from GitHub to the site packages (as if it was a pip install).
|
|
1267
1269
|
|
|
1268
|
-
With `install
|
|
1270
|
+
With `install peek.py`, you can install the peek.py in your current directory to the site packages (as if it was a pip install).
|
|
1269
1271
|
|
|
1270
|
-
Both files can be found in the GitHub repository (https://github.com/salabim/
|
|
1272
|
+
Both files can be found in the GitHub repository (https://github.com/salabim/peek).
|
|
1271
1273
|
|
|
1272
1274
|
|
|
1273
1275
|
# Limitations
|
|
1274
1276
|
|
|
1275
|
-
It is not possible to use
|
|
1277
|
+
It is not possible to use peek:
|
|
1276
1278
|
* from a frozen application (e.g. packaged with PyInstaller)
|
|
1277
1279
|
* when the underlying source code has changed during execution
|
|
1278
1280
|
|
|
1279
1281
|
# Implementation details
|
|
1280
1282
|
|
|
1281
1283
|
Although not important for using the package, here are some implementation details:
|
|
1282
|
-
*
|
|
1284
|
+
* peek.py contains the complete source of the asttokens and executing packages, in
|
|
1283
1285
|
order to offer the required source lookups, without any dependencies
|
|
1284
|
-
*
|
|
1285
|
-
* in order to support using
|
|
1286
|
-
any source file that uses
|
|
1286
|
+
* peek.py contains the complete source of pprint as of Python 3.13 in order to support the sort_dicts and underscore_numbers parameter
|
|
1287
|
+
* in order to support using peek() as a decorator and a context manager, peek caches the complete source of
|
|
1288
|
+
any source file that uses peek()
|
|
1289
|
+
|
|
1290
|
+
# Changelog
|
|
1291
|
+
|
|
1292
|
+
The changelog can be found here:
|
|
1293
|
+
|
|
1294
|
+
* https://github.com/salabim/peek/main/peek.md or
|
|
1295
|
+
* https://salabim.org/peek/changelog.html
|
|
1287
1296
|
|
|
1288
1297
|
|
|
1289
1298
|
# Acknowledgement
|
|
1290
1299
|
|
|
1291
|
-
The **
|
|
1300
|
+
The **peek** pacakage is inspired by the **IceCream** package, but is a
|
|
1292
1301
|
nearly complete rewrite. See https://github.com/gruns/icecream
|
|
1293
1302
|
|
|
1294
1303
|
Many thanks to the author Ansgar Grunseid / grunseid.com / grunseid@gmail.com .
|
|
1295
1304
|
|
|
1305
|
+
The peek package is a rebrand of the **ycecream** package, with enhancements.
|
|
1306
|
+
|
|
1296
1307
|
# Differences with IceCream
|
|
1297
1308
|
|
|
1298
|
-
The
|
|
1309
|
+
The peek module was originally a fork of **IceCream**, but has many differences:
|
|
1299
1310
|
|
|
1300
1311
|
```
|
|
1301
1312
|
----------------------------------------------------------------------------------------
|
|
1302
|
-
characteristic
|
|
1313
|
+
characteristic peek IceCream
|
|
1303
1314
|
----------------------------------------------------------------------------------------
|
|
1304
|
-
default name
|
|
1315
|
+
default name peek ic
|
|
1316
|
+
import method import peek from ycecream import ic
|
|
1305
1317
|
dependencies none many
|
|
1306
1318
|
number of files 1 several
|
|
1307
1319
|
usable without installation yes no
|
|
@@ -1324,8 +1336,8 @@ test script pytest unittest
|
|
|
1324
1336
|
colourize no yes (can be disabled)
|
|
1325
1337
|
----------------------------------------------------------------------------------------
|
|
1326
1338
|
```
|
|
1327
|
-
  
|
|
1328
1340
|
|
|
1329
|
-
 
|
|
1342
|
+

|
|
1331
1343
|
|