Access object within another objects in Python Last Updated : 15 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Prerequisite: Basics of OOPs in Python In this article, we will learn how to access object methods and attributes within other objects in Python. If we have two different classes and one of these defined another class on calling the constructor. Then, the method and attributes of another class can be accessed by first class objects ( i.e; objects within objects ). Here in the below example we learn to access object (its methods and attributes) within an object. We define two classes (class first and class second) with proper definitions. First class consists of a constructor and a method.The constructor form an object of the second class in the attribute of the first class.The method defines the presence in first class method.Similarly, the second class consists of a constructor and a method.The constructor form an attribute.The method defines the presence in the second class method. As the attribute of first class work as an object of the second class so all the methods and attributes of the second class can be accessed using this: object_of_first_class.attribute_of_first_class Below is the implementation: Python3 # python program to understand the # accessing of objects within objects # define class first class first: # constructor def __init__(self): # class second object # is created self.fst = second() def first_method(self): print("Inside first method") # define class second class second: # constructor def __init__(self): self.snd = "GFG" def second_method(self): print("Inside second method") # make object of first class obj1 = first() print(obj1) # make object of second class # with the help of first obj2 = obj1.fst print(obj2) # access attributes and methods # of second class print(obj2.snd) obj2.second_method() # This code is contributed # by Deepanshu Rustagi. Output: <__main__.first object at 0x7fde6c57b828> <__main__.second object at 0x7fde6c57b898> GFG Inside second method Comment More infoAdvertise with us Next Article Python - Access Parent Class Attribute D deepanshu_rustagi Follow Improve Article Tags : Python python-oop-concepts Python-OOP Practice Tags : python Similar Reads How to Access dict Attribute in Python In Python, A dictionary is a type of data structure that may be used to hold collections of key-value pairs. A dictionary's keys are connected with specific values, and you can access these values by using the keys. When working with dictionaries, accessing dictionary attributes is a basic function 6 min read How to Print Object Attributes in Python In Python, objects are the cornerstone of its object-oriented programming paradigm. An object is an instance of a class, and it encapsulates both data (attributes) and behaviors (methods). Understanding how to access and print the attributes of an object is fundamental for debugging, inspecting, and 2 min read Searching a list of objects in Python Searching for a single or group of objects can be done by iterating through a list. You might want to search a list of objects to find the object in the list of objects. It is very hard to look for objects manually, you can use the below-discussed method to search for objects in a list. You can also 3 min read Python - Access Parent Class Attribute A class is a user-defined blueprint or prototype from which objects are created. Classes provide a means of bundling data and functionality together. Creating a new class creates a new type of object, allowing new instances of that type to be made. Each class instance can have attributes attached to 4 min read Python - Access Parent Class Attribute A class is a user-defined blueprint or prototype from which objects are created. Classes provide a means of bundling data and functionality together. Creating a new class creates a new type of object, allowing new instances of that type to be made. Each class instance can have attributes attached to 4 min read Creating Instance Objects in Python In Python, an instance object is an individual object created from a class, which serves as a blueprint defining the attributes (data) and methods (functions) for the object. When we create an object from a class, it is referred to as an instance. Each instance has its own unique data but shares the 3 min read Like