[Python-Dev] Call for prudence about PEP-572

Eric V. Smith eric at trueblade.com
Sun Jul 8 07:03:32 EDT 2018


On 7/8/2018 5:41 AM, Giampaolo Rodola' wrote:
> As for "assert" what I'm concern about is the proliferation of things 
> like this:
>      class Foo:
>          def __init__(self):
>              assert self.x := fun1()
>              assert self.y := fun2()
>              assert self.z := fun3()
> 
> When I look at that my brain tells me that the main subject of the line 
> is "assert", not the assignment, but maybe it's just because I'm not 
> used to it. That aside there's the question of what to do when "python 
> -O" switch is used. With this in place "-O" would acquire a new meaning, 
> as it would disable "assert" statements AND assignments.

It has always meant "disable the assert statement and therefore any side 
effects the expression has". It's just that now the side effects are 
more obvious, or maybe easier to create. Even pre-572 I've been bitten 
by this, I'm ashamed to admit.

Eric



More information about the Python-Dev mailing list