[Python-checkins] r74152 - python/trunk/Doc/reference/simple_stmts.rst

Georg Brandl g.brandl at gmx.net
Wed Jul 22 16:24:16 CEST 2009


Benjamin Peterson schrieb:
> 2009/7/22 Nick Coghlan <ncoghlan at gmail.com>:
>> benjamin.peterson wrote:
>>> Author: benjamin.peterson
>>> Date: Wed Jul 22 02:03:43 2009
>>> New Revision: 74152
>>>
>>> Log:
>>> simplify
>>>
>>> Modified:
>>>    python/trunk/Doc/reference/simple_stmts.rst
>>>
>>> Modified: python/trunk/Doc/reference/simple_stmts.rst
>>> ==============================================================================
>>> --- python/trunk/Doc/reference/simple_stmts.rst       (original)
>>> +++ python/trunk/Doc/reference/simple_stmts.rst       Wed Jul 22 02:03:43 2009
>>> @@ -282,13 +282,13 @@
>>>
>>>  The simple form, ``assert expression``, is equivalent to ::
>>>
>>> -   if __debug__:
>>> -      if not expression: raise AssertionError
>>> +   if __debug__ and not expression:
>>> +       raise AssertionError
>>>
>>>  The extended form, ``assert expression1, expression2``, is equivalent to ::
>>>
>>> -   if __debug__:
>>> -      if not expression1: raise AssertionError(expression2)
>>> +   if __debug__ and not expression1:
>>> +       raise AssertionError(expression2)
>>
>> This change is incorrect as the compiler only optimises away statements
>> specifically of the form "if __debug__:". As soon as you put anything
>> else in the expression, the compiler no longer detects it as a candidate
>> for elimination.
> 
> Yeah, but whether it's optimized out in the form is an implementation detail.

I still find it cleaner in the original form (or a PEP8ified version with
a real suite), please revert.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Python-checkins mailing list