Browse Source

Introspection

pull/192/head
Jure Šorn 4 months ago
parent
commit
381dc91c9c
2 changed files with 2 additions and 2 deletions
  1. 2
      README.md
  2. 2
      index.html

2
README.md

@ -2235,7 +2235,7 @@ Introspection
```
```python
<list> = dir(<obj>) # Returns names of all object's attributes (incl. methods).
<list> = dir(<obj>) # Returns names of object's attributes (including 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.

2
index.html

@ -1831,7 +1831,7 @@ CRITICAL:my_module:Running out of disk space.
&lt;dict&gt; = globals() <span class="hljs-comment"># Dict of global names and their objects, e.g. __builtin__.</span>
</code></pre></div>
<pre><code class="python language-python hljs">&lt;list&gt; = dir(&lt;obj&gt;) <span class="hljs-comment"># Returns names of all object's attributes (incl. methods).</span>
<pre><code class="python language-python hljs">&lt;list&gt; = dir(&lt;obj&gt;) <span class="hljs-comment"># Returns names of object's attributes (including methods).</span>
&lt;dict&gt; = vars(&lt;obj&gt;) <span class="hljs-comment"># Returns dict of writable attributes. Also &lt;obj&gt;.__dict__.</span>
&lt;bool&gt; = hasattr(&lt;obj&gt;, <span class="hljs-string">'&lt;name&gt;'</span>) <span class="hljs-comment"># Checks if object possesses attribute with passed name.</span>
value = getattr(&lt;obj&gt;, <span class="hljs-string">'&lt;name&gt;'</span>) <span class="hljs-comment"># Returns object's attribute or raises AttributeError.</span>

Loading…
Cancel
Save