Python Passing Members Class

It is possible to pass the members (i.e. attributes and methods) of a class to another class.

let's create an instance of Emp class as:

e = Emp()

Then pass this instance 'e' to a method of other class, as:


Here, Myclass is the other class and mymethod() is a static method that belongs to Myclass. In Myclass, the method mymethod() will be declared as a static method as it acts neither on the class variables nor instance variables of Myclass. The purpose of mymethod() is to change the attribute of Emp class.

A Python program to create Emp class and make all the members of the Emp class available to another class, i.e. Myclass.

Let's understand that static methods are used when the class variables or instance variables are not disturbed. We have to use a static method when we want to pass some values from outside and perform some calculation in the method. Here, we are not touching the class variable or instance variables. Following program shows a static method that calculates the value of a number raised to a power.

A Python program to calculate power value of a number with the help of a static method.