Home » Python » How to Create Empty Class in Python?

How to Create Empty Class in Python?

In Python, you can create an empty class by using the pass command after the definition of the class object, because one line of code is compulsory for creating a class. Pass command in Python is a null statement; it does nothing when executes. The following is an example of an empty class object in Python.

Create an Empty Class in Python Example

In the below Python program, we will create an empty class customer. However, we can still define the objects outside of the customer class and would be able to use in our Python program.

class customer:

customer1 = customer()

customer1.first_name = 'John'
customer1.last_name = 'Greenberg'

customer2 = customer()

customer2.first_name = 'Nancy'
customer2.last_name = 'Lorrentz'
#customer 2 is also having a phone number
customer2.phone = '893-039-239'

print('Customer 1:', customer1.first_name, customer1.last_name)
print('Customer 2:', customer2.first_name, customer2.last_name, 'Phone No.', customer2.phone)


Customer 1: John Greenberg
Customer 2: Nancy Lorrentz Phone No. 893-039-239

See also: