Instance variable name a reserved word in Python
<p>I checked the Python style guide, and I found no specific references to having instance variable names with reserved words e.g. <code>self.type</code>, <code>self.class</code>, etc.</p>

<p>What's the best practice for this?</p>

<p>Avoid it if possible.</p>

<p>You can get and set such attributes via <code>getattr</code> and <code>setattr</code>, but they can't be accessed with ordinary dot syntax (something like <code>obj.class</code> is a syntax error), so they're a pain to use.</p>

<p>As Aurora0001 mentioned in a comment, a convention if you "need" to use them is to append an underscore.  The most common reason to "need" to have such attributes is that they're generated programatically from an external data source.</p>

<p>(Note that <code>type</code> is not a keyword, so you can do <code>self.type</code> just fine.)</p>

python