The process of identifying and fixing the bug is called debugging.
Very common way of debugging is to use print() statement. But the problem with the print() statement is, after fixing the bug, compulsorily we have to delete the extra added print() statements, otherwise these will be executed at runtime which creates performance problems and disturbs console output.
To overcome this problem we should go for assert statement. The main advantage of assert statement over print() statement is, after fixing bug we are not required to delete assert statements. Based on our requirement we can enable or disable assert statements.
Hence the main purpose of assertions is to perform debugging. Usually we can perform debugging either in development or in test environments but not in production environment. Hence assertions concept is applicable only for dev and test environments but not for production environment.
Types of assert statements:
There are 2 types of assert statements
Simple Version
Augmented Version
No comments:
Post a Comment
Thank you Very Much.For Given Comment