0

Why assertions are so important in Python?

Cose if you know the error why you can't just fix it? Can anyone give me "real life example", maybe when i have 1000 lines of code it is important? I was reading lesson about assertions but still don't get when i should use it and don't just fix the error in code line.

12th Jun 2020, 6:44 AM
Martyna Tomaszewska
Martyna Tomaszewska - avatar
1 Answer
+ 1
They are meant for user error. If you didnt write the program, odds are you dont know everything about it. Exception raising and handling takes care of mistakes that the user makes while entering input. If my program asks for a birthdate but the user supplies a name, the program should raise an error or not let the user continue until the correct form of data is entered
12th Jun 2020, 8:33 AM
Slick
Slick - avatar