From 3194abebcfc80b731fa71f9ec85c59c559ee40bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sat, 26 Oct 2024 04:50:59 +0200 Subject: [PATCH] Introspection rewrite --- README.md | 26 +++++++++++++------------- index.html | 30 +++++++++++++++--------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index b9eeb83..0889a7b 100644 --- a/README.md +++ b/README.md @@ -2294,25 +2294,25 @@ CRITICAL:my_module:Running out of disk space. Introspection ------------- ```python - = dir() # Names of local vars, functions, classes and modules. - = vars() # Dict of local vars, functions, etc. Also locals(). - = globals() # Dict of global vars, etc. (including '__builtins__'). + = dir() # List of of local names (including functions and classes). + = vars() # Dict of local names and their objects. Also locals(). + = globals() # Dict of global names (for instance '__builtin__' module). ``` ```python - = dir() # Names of all object's attributes (including methods). - = vars() # Dict of writable attributes. Also .__dict__. - = hasattr(, '') # Checks if getattr() raises AttributeError. -value = getattr(, '') # Default value can be passed as the third argument. -setattr(, '', value) # Only works on objects with __dict__ attribute. -delattr(, '') # Same. Also `del .`. + = dir() # Returns names of all object's attributes (incl. methods). + = vars() # Returns dict of writable attributes. Also .__dict__. + = hasattr(, '') # Checks if object possesses attribute with passed name. +value = getattr(, '') # Returns object's attribute or raises AttributeError. +setattr(, '', value) # Sets attribute. Only works on objects with __dict__. +delattr(, '') # Deletes attribute from __dict__. Also `del .`. ``` ```python - = inspect.signature() # Returns function's Signature object. - = .parameters # Dict of Parameters. Also .return_annotation. - = .kind # Member of ParamKind enum (Parameter.KEYWORD_ONLY, …). - = .default # Parameter.empty if missing. Also .annotation. + = inspect.signature() # Returns function's Signature object. Can accept a class. + = .parameters # Returns dict of Parameters. Also .return_annotation. + = .kind # Returns ParameterKind member (Parameter.KEYWORD_ONLY, …). + = .annotation # Returns Parameter.empty if missing. Also .default. ``` diff --git a/index.html b/index.html index 7dc8158..b433a13 100644 --- a/index.html +++ b/index.html @@ -55,7 +55,7 @@
- +
@@ -1877,22 +1877,22 @@ CRITICAL:my_module:Running out of disk space. 2023-02-07 23:21:01,430 CRITICAL:my_module:Running out of disk space. -

#Introspection

<list> = dir()                          # Names of local vars, functions, classes and modules.
-<dict> = vars()                         # Dict of local vars, functions, etc. Also locals().
-<dict> = globals()                      # Dict of global vars, etc. (including '__builtins__').
+

#Introspection

<list> = dir()                      # List of of local names (including functions and classes).
+<dict> = vars()                     # Dict of local names and their objects. Also locals().
+<dict> = globals()                  # Dict of global names (for instance '__builtin__' module).
 
-
<list> = dir(<obj>)                     # Names of all object's attributes (including methods).
-<dict> = vars(<obj>)                    # Dict of writable attributes. Also <obj>.__dict__.
-<bool> = hasattr(<obj>, '<attr_name>')  # Checks if getattr() raises AttributeError.
-value  = getattr(<obj>, '<attr_name>')  # Default value can be passed as the third argument.
-setattr(<obj>, '<attr_name>', value)    # Only works on objects with __dict__ attribute.
-delattr(<obj>, '<attr_name>')           # Same. Also `del <object>.<attr_name>`.
+
<list> = dir(<obj>)                 # Returns names of all object's attributes (incl. methods).
+<dict> = vars(<obj>)                # Returns dict of writable attributes. Also <obj>.__dict__.
+<bool> = hasattr(<obj>, '<name>')   # Checks if object possesses attribute with passed name.
+value  = getattr(<obj>, '<name>')   # Returns object's attribute or raises AttributeError.
+setattr(<obj>, '<name>', value)     # Sets attribute. Only works on objects with __dict__.
+delattr(<obj>, '<name>')            # Deletes attribute from __dict__. Also `del <obj>.<name>`.
 
-
<Sig>  = inspect.signature(<function>)  # Returns function's Signature object.
-<dict> = <Sig>.parameters               # Dict of Parameters. Also <Sig>.return_annotation.
-<memb> = <Param>.kind                   # Member of ParamKind enum (Parameter.KEYWORD_ONLY, …).
-<obj>  = <Param>.default                # Parameter.empty if missing. Also <Param>.annotation.
+
<Sig>  = inspect.signature(<func>)  # Returns function's Signature object. Can accept a class.
+<dict> = <Sig>.parameters           # Returns dict of Parameters. Also <Sig>.return_annotation.
+<memb> = <Param>.kind               # Returns ParameterKind member (Parameter.KEYWORD_ONLY, …).
+<type> = <Param>.annotation         # Returns Parameter.empty if missing. Also <Param>.default.
 

#Coroutines

  • Coroutines have a lot in common with threads, but unlike threads, they only give up control when they call another coroutine and they don’t use as much memory.
  • @@ -2927,7 +2927,7 @@ $ deactivate # Deactivates the active