From 59f26a5423f3bf5736e187985b2e24755790a9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 7 Oct 2024 23:23:05 +0200 Subject: [PATCH] Duck types --- README.md | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d2a3433..bd1c655 100644 --- a/README.md +++ b/README.md @@ -1183,7 +1183,7 @@ class Counter: ### Callable * **All functions and classes have a call() method, hence are callable.** -* **To check if object is callable use `'callable()'`, `'isinstance(, collections.abc.Callable)'`, or `'isinstance(, typing.Callable)'`.** +* **Use `'callable()'` or `'isinstance(, collections.abc.Callable)'` to check if object is callable.** * **When this cheatsheet uses `''` as an argument, it means `''`.** ```python class Counter: diff --git a/index.html b/index.html index 568616c..a5f7742 100644 --- a/index.html +++ b/index.html @@ -998,7 +998,7 @@ Z = dataclasses.make_dataclass('Z', [File objects returned by the open() function, etc.

Callable

  • All functions and classes have a call() method, hence are callable.
  • -
  • To check if object is callable use 'callable(<obj>)', 'isinstance(<obj>, collections.abc.Callable)', or 'isinstance(<obj>, typing.Callable)'.
  • +
  • Use 'callable(<obj>)' or 'isinstance(<obj>, collections.abc.Callable)' to check if object is callable.
  • When this cheatsheet uses '<function>' as an argument, it means '<callable>'.
class Counter:
     def __init__(self):