<dict> = vars(<object>) <spanclass="hljs-comment"># Dict of object's fields. Also <obj>.__dict__.</span>
<dict> = vars(<object>) <spanclass="hljs-comment"># Dict of object's fields. Also <obj>.__dict__.</span>
</code></pre></div>
<pre><codeclass="python language-python hljs"><bool> = hasattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>) <spanclass="hljs-comment"># Checks if getattr() raises an error.</span>
<bool> = hasattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>) <spanclass="hljs-comment"># Checks if getattr() raises an error.</span>
value = getattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>) <spanclass="hljs-comment"># Raises AttributeError if attribute is missing.</span>
value = getattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>) <spanclass="hljs-comment"># Raises AttributeError if attribute is missing.</span>
setattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>, value) <spanclass="hljs-comment"># Only works on objects with __dict__ attribute.</span>
setattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>, value) <spanclass="hljs-comment"># Only works on objects with __dict__ attribute.</span>
delattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>) <spanclass="hljs-comment"># Equivalent to `del <object>.<attr_name>`.</span>
delattr(<object>, <spanclass="hljs-string">'<attr_name>'</span>) <spanclass="hljs-comment"># Equivalent to `del <object>.<attr_name>`.</span>