{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "[Python for Developers](http://ricardoduarte.github.io/python-for-develoepers/#content)\n", "===================================\n", "First Edition\n", "-----------------------------------\n", "\n", "Chapter 14: Introspection\n", "=============================\n", "_____________________________\n", "Introspection or reflection is the ability of software to identify and report its own internal structures, such as types, variable scope, methods and attributes.\n", "\n", "Native interpreter functions for introspection:\n", "
Function | \n", "Returns | \n", "
---|---|
type(object) | \n",
" The typo (class) of the object | \n", "
id(object) | \n",
" object identifier | \n", "
locals() | \n",
" local variables dictionary | \n", "
globals() | \n",
" global variables dictionary | \n", "
vars(object) | \n",
" object symbols dictionary | \n", "
len(object) | \n",
" size of an object | \n", "
dir(object) | \n",
" A list of object structures | \n", "
help(object) | \n",
" Object doc strings | \n", "
repr(object) | \n",
" Object representation | \n", "
isinstance(object, class) | \n",
" True if object is derived from class | \n", "
issubclass(subclass, class) | \n",
" True if object inherits the class | \n", "