Skip to content

Commit 02a7836

Browse files
authored
Merge pull request gto76#28 from martinhanzalek/master
Hi, I propose some changes to your cheatcheat.
2 parents 69ee037 + 52e4027 commit 02a7836

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,8 +1214,8 @@ import os
12141214

12151215
### Subprocess
12161216
```python
1217-
>>> import subprocess
1218-
>>> a = subprocess.run(['ls', '-a'], stdout=subprocess.PIPE)
1217+
>>> import subprocess, shlex
1218+
>>> a = subprocess.run(shlex.split('ls -a'), stdout=subprocess.PIPE)
12191219
>>> a.stdout
12201220
b'.\n..\nfile1.txt\nfile2.txt\n'
12211221
>>> a.returncode
@@ -1456,6 +1456,12 @@ lock.acquire()
14561456
...
14571457
lock.release()
14581458
```
1459+
or
1460+
```python
1461+
lock = RLock()
1462+
with lock:
1463+
...
1464+
```
14591465

14601466

14611467
Introspection
@@ -1765,6 +1771,13 @@ logger.<level>('A logging message')
17651771
```
17661772
* **Levels: `'debug'`, `'info'`, `'success'`, `'warning'`, `'error'`, `'critical'`.**
17671773

1774+
```python
1775+
try:
1776+
...
1777+
except Exception as e:
1778+
logger.exception('An error happened', e)
1779+
```
1780+
17681781
### Rotation
17691782
**Parameter that sets a condition when a new log file is created.**
17701783
```python

0 commit comments

Comments
 (0)