osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] PEP 572 and assert


On Wed, Jul 18, 2018 at 03:41:08AM +1000, Steven D'Aprano wrote:

> Besides, there is a legitimate use for assignment expressions in 
> assertions:
> 
>     assert (spam := something) > 2, 'not enough spam'
>     assert  sequence[foo] == 999, 'sequence item isn't 999'

Ah, obviously the index in the second line ought to be spam, not foo.


-- 
Steve