pydoc > types

📛 NAME

types - Define names for built-in types that aren't directly accessible as a builtin.

🚀 Quick Reference

Use CaseCommandDescription
Check if an object is a functionisinstance(obj, types.FunctionType)Test for user-defined functions
Check if an object is a lambdaisinstance(obj, types.LambdaType)Alias for FunctionType
Create a coroutinetypes.coroutine(gen_func)Convert a generator function to an awaitable coroutine
Dynamically create a classtypes.new_class(name, bases, kwds, exec_body)Create a class object using the appropriate metaclass
Prepare a class namespacetypes.prepare_class(name, bases, kwds)Call __prepare__ of the metaclass, returns (metaclass, namespace, kwds)
Resolve MRO entriestypes.resolve_bases(bases)Resolve PEP 560 dynamic base classes
Wrap a dict as read-onlytypes.MappingProxyType(d)Create a read-only view of a mapping
Create a simple namespacetypes.SimpleNamespace(**kwargs)Attribute-based namespace object
Represent a union typeint | strtypes.UnionTypePEP 604 union type representation
Inspect a code objecttypes.CodeType(...)Create or replace a code object

📚 MODULE REFERENCE

https://docs.python.org/3.10/library/types.html

The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above.

🧬 CLASSES

🌀 AsyncGeneratorType

AsyncGeneratorType = class async_generator(object)

🔧 BuiltinFunctionType

BuiltinFunctionType = class builtin_function_or_method(object)

🔧 BuiltinMethodType

Same as BuiltinFunctionType (alias).

📦 CellType

CellType = class cell(object) — Create a new cell object.

📋 ClassMethodDescriptorType

ClassMethodDescriptorType = class classmethod_descriptor(object)

🖥️ CodeType

CodeType = class code(object)

CodeType(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, linetable, freevars=(), cellvars=(), /)

Create a code object. Not for the faint of heart.

🔄 CoroutineType

CoroutineType = class coroutine(object)

🪄 DynamicClassAttribute

DynamicClassAttribute(fget=None, fset=None, fdel=None, doc=None)

Route attribute access on a class to __getattr__. This is a descriptor, used to define attributes that act differently when accessed through an instance and through a class. Instance access remains normal, but access to an attribute through a class will be routed to the class's __getattr__ method; this is done by raising AttributeError.

This allows one to have properties active on an instance, and have virtual attributes on the class with the same name. (Enum used this between Python versions 3.4 - 3.9.)

Subclass from this to use a different method of accessing virtual atributes and still be treated properly by the inspect module. (Enum uses this since Python 3.10.)

📌 EllipsisType

EllipsisType = class ellipsis(object)

🖼️ FrameType

FrameType = class frame(object)

🟢 FunctionType

FunctionType = class function(object)

FunctionType(code, globals, name=None, argdefs=None, closure=None)

Create a function object.

⚙️ GeneratorType

GeneratorType = class generator(object)

🔗 GenericAlias

GenericAlias — Represent a PEP 585 generic type

E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).

🧲 GetSetDescriptorType

GetSetDescriptorType = class getset_descriptor(object)

🟢 LambdaType

Same as FunctionType (alias).

🗂️ MappingProxyType

MappingProxyType = class mappingproxy(object) — A read-only view of a mapping.

🧩 MemberDescriptorType

MemberDescriptorType = class member_descriptor(object)

📋 MethodDescriptorType

MethodDescriptorType = class method_descriptor(object)

🔗 MethodType

MethodType = class method(object)

method(function, instance)

Create a bound instance method object.

🔧 MethodWrapperType

MethodWrapperType = class method-wrapper(object)

📦 ModuleType

ModuleType = class module(object)

ModuleType(name, doc=None)

Create a module object. The name must be a string; the optional doc argument can have any type.

🚫 NoneType

NoneType = class NoneType(object) — The type of None.

🚫 NotImplementedType

NotImplementedType = class NotImplementedType(object) — The type of NotImplemented.

🏷️ SimpleNamespace

SimpleNamespace(**kwargs) — A simple attribute-based namespace.

📜 TracebackType

TracebackType = class traceback(object)

TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)

Create a new traceback object.

🔗 UnionType

UnionType — Represent a PEP 604 union type

E.g. for int | str.

🧲 WrapperDescriptorType

WrapperDescriptorType = class wrapper_descriptor(object)

🔧 FUNCTIONS

🔄 coroutine

coroutine(func)

Convert regular generator function to a coroutine.

🏗️ new_class

new_class(name, bases=(), kwds=None, exec_body=None)

Create a class object dynamically using the appropriate metaclass.

📋 prepare_class

prepare_class(name, bases=(), kwds=None)

Call the __prepare__ method of the appropriate metaclass.

Returns (metaclass, namespace, kwds) as a 3-tuple

🧩 resolve_bases

resolve_bases(bases)

Resolve MRO entries dynamically as specified by PEP 560.

📦 DATA

__all__ = ['FunctionType', 'LambdaType', 'CodeType', 'MappingProxyType', 'SimpleNamespace', 'GenericAlias', 'UnionType', 'DynamicClassAttribute', 'coroutine', 'new_class', 'prepare_class', 'resolve_bases']

📁 FILE

/usr/lib/python3.10/types.py
types
📛 NAME 🚀 Quick Reference 📚 MODULE REFERENCE 🧬 CLASSES
🌀 AsyncGeneratorType 🔧 BuiltinFunctionType 🔧 BuiltinMethodType 📦 CellType 📋 ClassMethodDescriptorType 🖥️ CodeType 🔄 CoroutineType 🪄 DynamicClassAttribute 📌 EllipsisType 🖼️ FrameType 🟢 FunctionType ⚙️ GeneratorType 🔗 GenericAlias 🧲 GetSetDescriptorType 🟢 LambdaType 🗂️ MappingProxyType 🧩 MemberDescriptorType 📋 MethodDescriptorType 🔗 MethodType 🔧 MethodWrapperType 📦 ModuleType 🚫 NoneType 🚫 NotImplementedType 🏷️ SimpleNamespace 📜 TracebackType 🔗 UnionType 🧲 WrapperDescriptorType
🔧 FUNCTIONS
🔄 coroutine 🏗️ new_class 📋 prepare_class 🧩 resolve_bases
📦 DATA 📁 FILE

Generated by phpman v4.9.27 · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-18 16:11 @216.73.216.114
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^