---
title: "Code Introspection in Python"  
description: "Introspection is an act of self examination and is the greatest strength of Python. As you know, everything in Python is an object, and introspection"  
author: "resma k"  
published: 2019-12-09  
updated: 2019-12-10  
canonical: https://www.mindstick.com/articles/290075/code-introspection-in-python  
category: "python"  
tags: ["python", "python-2.x", "python-3.x", "education", "programming language"]  
reading_time: 2 minutes  

---

# Code Introspection in Python

[Introspection](https://www.mindstick.com/interview/22832/define-class-introspection) is an act of self examination and is the greatest strength of Python. As you know, everything in Python is an object, and introspection is code looking at other modules and functions in memory as objects, getting information about them, and manipulating them. Along the way, you’ll [define functions](https://www.mindstick.com/interview/33884/how-do-you-define-functions-in-css-and-benefits) with no name, call functions with arguments out of order, and reference functions whose names you don’t even know ahead of time

To get in depth knowledge on Python you can enroll for free demo **Python [Online training](https://www.mindstick.com/forum/160848/which-gadgets-are-required-for-online-training)**

In computer programming, introspection is the ability to determine the type of an object at runtime. Python [programming language](https://www.mindstick.com/forum/156801/write-a-program-for-reverse-a-word-in-sentence-in-any-programming-language) has a large support of introspection. Everything in Python is an object. Every object in Python may have [attributes](https://www.mindstick.com/interview/34453/what-are-attributes-in-dot-net) and methods. By using introspection, we can dynamically inspect Python objects.

Introspection reveals useful information about [your program](https://answers.mindstick.com/qa/33494/how-do-you-find-any-view-element-into-your-program-explain-for-example)’s **objects. Python**, being a dynamic, object-[oriented programming](https://www.mindstick.com/interview/23571/what-is-the-difference-between-object-oriented-programming-and-object-based-programming) language, provides tremendous introspection support. Python’s support for introspection runs deep and wide throughout the language. In fact, it would be hard to imagine Python without its introspection features. It has the ability to determine the type of an object at runtime. Henceforth, by using introspection, we dynamically inspect the Python objects.

Code introspection is required for examining into other modules, classes, functions, keywords or objects and retrieving information about them so that [manipulation](https://www.mindstick.com/forum/34588/list-manipulation) can be carried out, [if necessary](https://www.mindstick.com/forum/23229/in-python-check-if-a-directory-exists-and-create-it-if-necessary). Python provides several functions and utilities for code introspection. Along with it, you can also define call functions and reference functions with no name .

Learn for more what are the **Python functions**

Built- in functions mentioned in the chapter on functions are used for code introspection. Have a look at some of the following examples.

![Code Introspection in Python](https://www.mindstick.com/mindstickarticle/a696cd54-0c38-4dff-9414-f08c16bdc82e/images/68371c5a-1762-429f-a415-1b9285435811.png)\

---

Original Source: https://www.mindstick.com/articles/290075/code-introspection-in-python

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
