assert <expr>, <expr>
compiles to basically…
if not <expr>:
raise AssertionError(<expr>)
- Use
assert
when guarding a program against bugs inside itself (invariants) - Don’t use
assert
to defend against issues coming from the outside world
Original video by anthonywritescode:
today I talk about the `assert` statement, what it is, how it works, and why some will flag it as a “security” issue.
playlist: https://www.youtube.com/playlist?list=PLWBKAf81pmOaP9naRiNAqug6EBnkPakvY
==========
twitch: https://twitch.tv/anthonywritescode
dicsord: https://discord.gg/xDKGPaW
twitter: https://twitter.com/codewithanthony
github: https://github.com/asottile
stream github: https://github.com/anthonywritescode
I won’t ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you’d like to see please comment below!