From 92695eb6541b088d04a2c3af77317486ebaadb77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 28 May 2020 01:01:09 +0200 Subject: [PATCH] Introspection --- README.md | 3 --- index.html | 7 +++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f4d14f8..90145d3 100644 --- a/README.md +++ b/README.md @@ -2142,9 +2142,6 @@ Introspection ```python = dir() # Names of object's attributes (incl. methods). = vars() # Dict of object's fields. Also .__dict__. -``` - -```python = hasattr(, '') # Checks if getattr() raises an error. value = getattr(, '') # Raises AttributeError if attribute is missing. setattr(, '', value) # Only works on objects with __dict__ attribute. diff --git a/index.html b/index.html index 3832124..8cd8033 100644 --- a/index.html +++ b/index.html @@ -1875,13 +1875,12 @@ last_el = op.methodcaller('pop')(<l

Attributes

<list> = dir(<object>)                     # Names of object's attributes (incl. methods).
 <dict> = vars(<object>)                    # Dict of object's fields. Also <obj>.__dict__.
-
- -
<bool> = hasattr(<object>, '<attr_name>')  # Checks if getattr() raises an error.
+<bool> = hasattr(<object>, '<attr_name>')  # Checks if getattr() raises an error.
 value  = getattr(<object>, '<attr_name>')  # Raises AttributeError if attribute is missing.
 setattr(<object>, '<attr_name>', value)    # Only works on objects with __dict__ attribute.
 delattr(<object>, '<attr_name>')           # Equivalent to `del <object>.<attr_name>`.
-
+ +

Parameters

from inspect import signature
 <sig>        = signature(<function>)
 no_of_params = len(<sig>.parameters)