[Python-Dev] PEP 572 and assert (original) (raw)
Steven D'Aprano steve at pearwood.info
Tue Jul 17 19:33:24 EDT 2018
- Previous message (by thread): [Python-Dev] PEP 572 and assert
- Next message (by thread): [Python-Dev] PEP 572 and assert
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): [Python-Dev] PEP 572 and assert
- Next message (by thread): [Python-Dev] PEP 572 and assert
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]