Created
May 11, 2024 10:18
-
-
Save mypy-play/896b3c93cfd8a39cba0839c43650e9c9 to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections.abc import Callable | |
def pprint(obj: object, repr_fn: Callable[..., str] = NotImplemented): | |
repr_fn = ( | |
repr_fn # expression has type "function", variable has type "Callable[..., str]" | |
if repr_fn is not NotImplemented | |
else repr | |
) | |
return repr_fn(obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment