<p><a href="https://www.python.org/dev/peps/pep-0008/#function-and-method-arguments" rel="nofollow">PEP 8 addresses this pretty clearly:</a></p>
<blockquote>
<p>Always use self for the first argument to instance methods.</p>
<p>Always use cls for the first argument to class methods.</p>
</blockquote>
<p>虽然还记得作为python <a href="https://www.python.org/dev/peps/pep-0008/#a-foolish-consistency-is-the-hobgoblin-of-little-minds" rel="nofollow"><em>style guide</em> this is <strong>not enforced</strong></a></p>
<blockquote>
<p>However, know when to be inconsistent -- sometimes style guide
recommendations just aren't applicable. When in doubt, use your best
judgment. Look at other examples and decide what looks best.</p>
</blockquote>
<p>有时,像<a href="https://github.com/tadhgmister/cpython/blob/master/Lib/fractions.py#L401" rel="nofollow">in ^{<cd1>}</a>,使用类似<code>a,b</code>而不是{<cd3>}的东西可能会更清楚,因为<code><your specific reasons></code></p>
<p>《风格指南》实际上在上面的引文下面列出了一些可能打破惯例的原因:</p>
<blockquote>
<p>Some other good reasons to ignore a particular guideline:</p>
<ol>
<li>When applying the guideline would make the code less readable, even for someone who is used to reading code that follows this PEP.</li>
<li>To be consistent with surrounding code that also breaks it (maybe for historic reasons) -- although this is also an opportunity to clean
up someone else's mess (in true XP style).</li>
<li>Because the code in question predates the introduction of the guideline and there is no other reason to be modifying that code.</li>
<li>When the code needs to remain compatible with older versions of Python that don't support the feature recommended by the style guide.</li>
</ol>
</blockquote>