mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-04-23 03:00:38 -04:00
Add Python Highlighting to Python Code
This commit is contained in:
committed by
Ram Rachum
parent
3d0d0515c3
commit
19122df94b
28
README.md
28
README.md
@@ -17,22 +17,22 @@ What makes **PySnooper** stand out from all other code intelligence tools? You c
|
||||
# Example #
|
||||
|
||||
We're writing a function that converts a number to binary, by returning a list of bits. Let's snoop on it by adding the `@pysnooper.snoop()` decorator:
|
||||
```python
|
||||
import pysnooper
|
||||
|
||||
import pysnooper
|
||||
|
||||
@pysnooper.snoop()
|
||||
def number_to_bits(number):
|
||||
if number:
|
||||
bits = []
|
||||
while number:
|
||||
number, remainder = divmod(number, 2)
|
||||
bits.insert(0, remainder)
|
||||
return bits
|
||||
else:
|
||||
return [0]
|
||||
|
||||
number_to_bits(6)
|
||||
@pysnooper.snoop()
|
||||
def number_to_bits(number):
|
||||
if number:
|
||||
bits = []
|
||||
while number:
|
||||
number, remainder = divmod(number, 2)
|
||||
bits.insert(0, remainder)
|
||||
return bits
|
||||
else:
|
||||
return [0]
|
||||
|
||||
number_to_bits(6)
|
||||
```
|
||||
The output to stderr is:
|
||||
|
||||
Starting var:.. number = 6
|
||||
|
||||
Reference in New Issue
Block a user