Browse Source
Merge pull request #28 from martinhanzalek/master
Hi, I propose some changes to your cheatcheat.
pull/45/head
Jure Šorn
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
15 additions and
2 deletions
-
README.md
|
|
@ -1214,8 +1214,8 @@ import os |
|
|
|
|
|
|
|
### Subprocess |
|
|
|
```python |
|
|
|
>>> import subprocess |
|
|
|
>>> a = subprocess.run(['ls', '-a'], stdout=subprocess.PIPE) |
|
|
|
>>> import subprocess, shlex |
|
|
|
>>> a = subprocess.run(shlex.split('ls -a'), stdout=subprocess.PIPE) |
|
|
|
>>> a.stdout |
|
|
|
b'.\n..\nfile1.txt\nfile2.txt\n' |
|
|
|
>>> a.returncode |
|
|
@ -1456,6 +1456,12 @@ lock.acquire() |
|
|
|
... |
|
|
|
lock.release() |
|
|
|
``` |
|
|
|
or |
|
|
|
```python |
|
|
|
lock = RLock() |
|
|
|
with lock: |
|
|
|
... |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
Introspection |
|
|
@ -1765,6 +1771,13 @@ logger.<level>('A logging message') |
|
|
|
``` |
|
|
|
* **Levels: `'debug'`, `'info'`, `'success'`, `'warning'`, `'error'`, `'critical'`.** |
|
|
|
|
|
|
|
```python |
|
|
|
try: |
|
|
|
... |
|
|
|
except Exception as e: |
|
|
|
logger.exception('An error happened', e) |
|
|
|
``` |
|
|
|
|
|
|
|
### Rotation |
|
|
|
**Parameter that sets a condition when a new log file is created.** |
|
|
|
```python |
|
|
|