Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 05ea5c0

Browse files
committed
Introspection
1 parent d1bdde4 commit 05ea5c0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,8 +2141,8 @@ Introspection
21412141
### Attributes
21422142
```python
21432143
<list> = dir(<object>) # Names of object's attributes (incl. methods).
2144-
<dict> = vars(<object>) # Dict of object's fields. Also <obj>.__dict__.
2145-
<bool> = hasattr(<object>, '<attr_name>') # Checks if getattr() raises an error.
2144+
<dict> = vars(<object>) # Dict of writable attrs. Also <obj>.__dict__.
2145+
<bool> = hasattr(<object>, '<attr_name>') # Checks if getattr() raises an AttributeError.
21462146
value = getattr(<object>, '<attr_name>') # Raises AttributeError if attribute is missing.
21472147
setattr(<object>, '<attr_name>', value) # Only works on objects with __dict__ attribute.
21482148
delattr(<object>, '<attr_name>') # Equivalent to `del <object>.<attr_name>`.

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,8 +1905,8 @@
19051905

19061906

19071907
<div><h3 id="attributes-1">Attributes</h3><pre><code class="python language-python hljs">&lt;list&gt; = dir(&lt;object&gt;) <span class="hljs-comment"># Names of object's attributes (incl. methods).</span>
1908-
&lt;dict&gt; = vars(&lt;object&gt;) <span class="hljs-comment"># Dict of object's fields. Also &lt;obj&gt;.__dict__.</span>
1909-
&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>
1908+
&lt;dict&gt; = vars(&lt;object&gt;) <span class="hljs-comment"># Dict of writable attrs. Also &lt;obj&gt;.__dict__.</span>
1909+
&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 AttributeError.</span>
19101910
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>
19111911
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>
19121912
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>

0 commit comments

Comments
 (0)