Super keyword in Python? | Example

There is no super keyword instead Super function is used in Python to give access to methods and properties of a parent or sibling class. Syntax This function returns an object that represents the parent class. Example Super keyword function in Python Simple example codes the class that will inherit all the methods and properties Read More…


Python global keyword | Change scope of variables

Python global keyword is used to change the scope of variables. By default variables inside the function has local scope. Means you can’t use it outside the function. Simple use global keyword to read and write a global variable inside a function. Note: If a variable defines outside the funciton it is global by default. Read More…


Why is it considered good practice to open a file from within a python script by using with keyword

Using Open a file from within a python script by using with keyword has an advantage because it is guaranteed to close the file no matter how the nested block exits. If an exception occurs before the end of the block, it will close the file before the exception is caught by an outer exception Read More…


Python with keyword | Example code

In python the with keyword is used when working with unmanaged resources (like file streams). . It provides ‘syntactic sugar’ for try/finally blocks. Syntax of with keyword Python Example of “with keyword” Simple example code. It creates a with-block that executes that usages the variable which is declared with “with keyword“. The with keyword is Read More…


Python with statement | Example code

Python with statement is used with try/finally statements. It is used with unmanaged resources (like file streams). The with the statement clarifies code that previously would use try…finally blocks to ensure that clean-up code is executed. Syntax Example “with statement” in Python Simple example code using “with statement”. In the normal file operation, we have Read More…



del keyword in Python | Example code

Python del keyword is used to delete objects. It could delete everything from an object like variables, lists, dictionaries, slice a list, etc. Examples del keyword in Python Simple example code to delete variables, lists, dictionaries, and class objects. Deleting variables Delete both the variables Output: Deleting list Output: NameError: name ‘list1’ is not defined Read More…


Python break Statement for Loop – While & For

Python break Statement (Keyword) used to break out a for loop or while loop. To a Loops you have to use the Break statement inside the loop body (generally after if condition). Why you needed to break a loop? Because if you have some external condition and want to end it. For example, you are Read More…


Python Continue Statement | How works For, while Loop Example

Python Continue Statement is a loop control statement and mainly used to skip an iteration or ignore that condition. It works opposite to that of a break statement. Where break statement is instead of terminating the loop and Continue Statement forces to execute the next iteration of the loop. There are more loop control statements. Read More…