Python Pass StatementWe will discover more about pass statements in this tutorial. It is interpreted as a placeholder for the future execution of functions, classes, loops, etc. What is Pass Statement in Python?The null statement is another name for the pass statement. A Comment is not ignored by the Python interpreter, whereas a pass statement is not. Hence, they two are different Python keywords. We can use the pass statement as a placeholder when unsure what code to provide. So, we only have to place the pass on that line. Pass may be used when we don't wish any code to be executed. We can simply insert a pass in places where empty code is prohibited, such as loops, functions, class definitions, or if-else statements. Syntax of the Pass Keyword Typically, we utilise it as a reference for the future. Let's say we have a loop or an if-else statement that isn't to be filled now but that we wish to in the future. The pass keyword cannot have an empty body as it will be syntactically wrong. An error would be displayed by the Python interpreter suggesting to fill the space. Therefore, we create a code block that performs nothing using the pass statement. Example of the Pass StatementCode Output: Not reached pass keyword: Python Not reached pass keyword: Placeholder Not reached pass keyword: Statement The same thing is also possible to create an empty function or a class. Code
Next TopicPython Strings
|
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week