擅长:python、mysql、java
<p>疏胜于密;)</p>
<pre><code>minscore = 1
if month:
minscore = 10
elif day:
minscore = 100
</code></pre>
<p>在<a href="http://www.python.org/dev/peps/pep-0008/" rel="nofollow">PEP 8</a>中也引用了这一点:</p>
<blockquote>
<p>Compound statements (multiple statements on the same line) are
generally discouraged.</p>
<p>Yes:</p>
</blockquote>
<pre><code>if foo == 'blah':
do_blah_thing() do_one() do_two() do_three()
</code></pre>
<blockquote>
<p>Rather not:</p>
</blockquote>
<pre><code>if foo == 'blah': do_blah_thing() do_one(); do_two(); do_three()
</code></pre>
<hr/>
<p>我猜条件语句(即三元表达式)可能是“最具pythonic”的方法,但我认为引用Python的Zen会更好。你知道吗</p>