diff options
| author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-04-27 01:19:35 +0200 |
|---|---|---|
| committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-04-27 01:19:35 +0200 |
| commit | d214ea04e72d7132c9598e89a2a1dd84a3cd3ee3 (patch) | |
| tree | f62e127cbf706720cf84e3364aada3cc1417af0d /docs | |
| parent | 9e34798ece5f231cafdd0da215c8b568b4f82d09 (diff) | |
| download | psutil-d214ea04e72d7132c9598e89a2a1dd84a3cd3ee3.tar.gz | |
update doc
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/index.rst | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/docs/index.rst b/docs/index.rst index 12ea4b7b..db65d3d5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -826,9 +826,9 @@ Functions >>> for proc in psutil.process_iter(attrs=['pid', 'name', 'username']): ... print(proc.info) ... - {'username': 'root', 'pid': 1, 'name': 'systemd'} - {'username': 'root', 'pid': 2, 'name': 'kthreadd'} - {'username': 'root', 'pid': 3, 'name': 'ksoftirqd/0'} + {'name': 'systemd', 'pid': 1, 'username': 'root'} + {'name': 'kthreadd', 'pid': 2, 'username': 'root'} + {'name': 'ksoftirqd/0', 'pid': 3, 'username': 'root'} ... Example of a dict comprehensions to create a ``{pid: info, ...}`` data @@ -842,6 +842,12 @@ Functions 3: {'name': 'ksoftirqd/0', 'username': 'root'}, ...} + Example showing how to filter processes by name:: + + >>> [p.info for p in psutil.process_iter(attrs=['pid', 'name']) if 'python' in p.info['name']] + [{'name': 'python3', 'pid': 21947}, + {'name': 'python', 'pid': 23835}] + .. versionchanged:: 5.3.0 added "attrs" and "ad_value" parameters. |
