Browse Source

Introspection

pull/57/head
Jure Šorn 4 years ago
parent
commit
716a966d97
2 changed files with 2 additions and 2 deletions
  1. 2
      README.md
  2. 2
      index.html

2
README.md

@ -2150,7 +2150,7 @@ Introspection
```python
<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 classes with __dict__ attribute.
setattr(<object>, '<attr_name>', value) # Only works on objects with __dict__ attribute.
delattr(<object>, '<attr_name>') # Equivalent to `del <object>.<attr_name>`.
```

2
index.html

@ -1882,7 +1882,7 @@ last_el = op.methodcaller(<span class="hljs-string">'pop'</span>)(&lt;l
<pre><code class="python language-python hljs">&lt;bool&gt; = hasattr(&lt;object&gt;, <span class="hljs-string">'&lt;attr_name&gt;'</span>) <span class="hljs-comment"># Checks if getattr() raises an error.</span>
value = getattr(&lt;object&gt;, <span class="hljs-string">'&lt;attr_name&gt;'</span>) <span class="hljs-comment"># Raises AttributeError if attribute is missing.</span>
setattr(&lt;object&gt;, <span class="hljs-string">'&lt;attr_name&gt;'</span>, value) <span class="hljs-comment"># Only works on classes with __dict__ attribute.</span>
setattr(&lt;object&gt;, <span class="hljs-string">'&lt;attr_name&gt;'</span>, value) <span class="hljs-comment"># Only works on objects with __dict__ attribute.</span>
delattr(&lt;object&gt;, <span class="hljs-string">'&lt;attr_name&gt;'</span>) <span class="hljs-comment"># Equivalent to `del &lt;object&gt;.&lt;attr_name&gt;`.</span>
</code></pre>
<div><h3 id="parameters-1">Parameters</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> inspect <span class="hljs-keyword">import</span> signature

Loading…
Cancel
Save