Closed h4l7 closed 11 months ago
Nope, it makes the API too complex both to use and to document.
Also, there would be no way to distinguish between "return {} for all APIs" vs. "here is a dict describing what each API should return", because they are both dicts.
If you want such a level of customization you are better off using the native APIs directly (cwd(), exe(), etc.), or write your own wrapper on top of them in way that is similar to as_dict().
Summary
Proposal to support
Dict[str, Any]
parameters forad_value
, so that each key provided inattrs
may have a custom default value.Description
As defined,
as_dict(attrs=None, ad_value=None)
only accepts a single default value for all keys provided inattrs
. This means that it's not possible to have different default values for each key inattrs
.For example, consider:
Relevant code snippet:
https://github.com/giampaolo/psutil/blob/master/psutil/__init__.py#L545
Function docs
https://psutil.readthedocs.io/en/latest/index.html#psutil.Process.as_dict
Thank you for your consideration.