MCPcopy Index your code
hub / github.com/python/cpython / describe

Function describe

Lib/pydoc.py:1639–1671  ·  view source on GitHub ↗

Produce a short description of the given thing.

(thing)

Source from the content-addressed store, hash-verified

1637 pager(text, title)
1638
1639def describe(thing):
1640 """Produce a short description of the given thing."""
1641 if inspect.ismodule(thing):
1642 if thing.__name__ in sys.builtin_module_names:
1643 return 'built-in module ' + thing.__name__
1644 if hasattr(thing, '__path__'):
1645 return 'package ' + thing.__name__
1646 else:
1647 return 'module ' + thing.__name__
1648 if inspect.isbuiltin(thing):
1649 return 'built-in function ' + thing.__name__
1650 if inspect.isgetsetdescriptor(thing):
1651 return 'getset descriptor %s.%s.%s' % (
1652 thing.__objclass__.__module__, thing.__objclass__.__name__,
1653 thing.__name__)
1654 if inspect.ismemberdescriptor(thing):
1655 return 'member descriptor %s.%s.%s' % (
1656 thing.__objclass__.__module__, thing.__objclass__.__name__,
1657 thing.__name__)
1658 if inspect.isclass(thing):
1659 return 'class ' + thing.__name__
1660 if inspect.isfunction(thing):
1661 return 'function ' + thing.__name__
1662 if inspect.ismethod(thing):
1663 return 'method ' + thing.__name__
1664 if inspect.ismethodwrapper(thing):
1665 return 'method wrapper ' + thing.__name__
1666 if inspect.ismethoddescriptor(thing):
1667 try:
1668 return 'method descriptor ' + thing.__name__
1669 except AttributeError:
1670 pass
1671 return type(thing).__name__
1672
1673def locate(path, forceload=0):
1674 """Locate an object by name or dotted path, importing as necessary."""

Callers 3

render_docFunction · 0.85
writedocFunction · 0.85
html_getobjFunction · 0.85

Calls 2

ismethodMethod · 0.80
ismoduleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…