おそらく信じられないほど些細な質問のように思えるかもしれませんが、私は興味があり、与えられました:
foo = {1: 'one', 2: 'two'}
次の 2 つのアプローチのいずれかを好む理由はありますか?
if not 3 in foo:
print 'bar'
if 3 not in foo:
print 'bar'
おそらく信じられないほど些細な質問のように思えるかもしれませんが、私は興味があり、与えられました:
foo = {1: 'one', 2: 'two'}
次の 2 つのアプローチのいずれかを好む理由はありますか?
if not 3 in foo:
print 'bar'
if 3 not in foo:
print 'bar'