Берет комментарии из кода и "pydoc - Generate Python documentation in HTML or text for interactive use". Можно распечатать документацию из командной строки, а можно из консоли. Об этом видеоролик. Я и распечатал здесь help(pydoc)
In []:
# В консоли работает - надо указать полный путь к pydoc.py
C:\Users\kiss\Documents\Python_Django\mysite_1>python C:\Users\kiss\Anaconda\Lib\pydoc.py math
In [1]:
import pydoc
Здесь кавычки нужны¶
In [5]:
help(math)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-5-86040611b48e> in <module>() ----> 1 help(math) NameError: name 'math' is not defined
In [3]:
help('math')
Help on built-in module math: NAME math FILE (built-in) DESCRIPTION This module is always available. It provides access to the mathematical functions defined by the C standard. FUNCTIONS acos(...) acos(x) Return the arc cosine (measured in radians) of x. acosh(...) acosh(x) Return the hyperbolic arc cosine (measured in radians) of x. asin(...) asin(x) Return the arc sine (measured in radians) of x. asinh(...) asinh(x) Return the hyperbolic arc sine (measured in radians) of x. atan(...) atan(x) Return the arc tangent (measured in radians) of x. atan2(...) atan2(y, x) Return the arc tangent (measured in radians) of y/x. Unlike atan(y/x), the signs of both x and y are considered. atanh(...) atanh(x) Return the hyperbolic arc tangent (measured in radians) of x. ceil(...) ceil(x) Return the ceiling of x as a float. This is the smallest integral value >= x. copysign(...) copysign(x, y) Return x with the sign of y. cos(...) cos(x) Return the cosine of x (measured in radians). cosh(...) cosh(x) Return the hyperbolic cosine of x. degrees(...) degrees(x) Convert angle x from radians to degrees. erf(...) erf(x) Error function at x. erfc(...) erfc(x) Complementary error function at x. exp(...) exp(x) Return e raised to the power of x. expm1(...) expm1(x) Return exp(x)-1. This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x. fabs(...) fabs(x) Return the absolute value of the float x. factorial(...) factorial(x) -> Integral Find x!. Raise a ValueError if x is negative or non-integral. floor(...) floor(x) Return the floor of x as a float. This is the largest integral value <= x. fmod(...) fmod(x, y) Return fmod(x, y), according to platform C. x % y may differ. frexp(...) frexp(x) Return the mantissa and exponent of x, as pair (m, e). m is a float and e is an int, such that x = m * 2.**e. If x is 0, m and e are both 0. Else 0.5 <= abs(m) < 1.0. fsum(...) fsum(iterable) Return an accurate floating point sum of values in the iterable. Assumes IEEE-754 floating point arithmetic. gamma(...) gamma(x) Gamma function at x. hypot(...) hypot(x, y) Return the Euclidean distance, sqrt(x*x + y*y). isinf(...) isinf(x) -> bool Check if float x is infinite (positive or negative). isnan(...) isnan(x) -> bool Check if float x is not a number (NaN). ldexp(...) ldexp(x, i) Return x * (2**i). lgamma(...) lgamma(x) Natural logarithm of absolute value of Gamma function at x. log(...) log(x[, base]) Return the logarithm of x to the given base. If the base not specified, returns the natural logarithm (base e) of x. log10(...) log10(x) Return the base 10 logarithm of x. log1p(...) log1p(x) Return the natural logarithm of 1+x (base e). The result is computed in a way which is accurate for x near zero. modf(...) modf(x) Return the fractional and integer parts of x. Both results carry the sign of x and are floats. pow(...) pow(x, y) Return x**y (x to the power of y). radians(...) radians(x) Convert angle x from degrees to radians. sin(...) sin(x) Return the sine of x (measured in radians). sinh(...) sinh(x) Return the hyperbolic sine of x. sqrt(...) sqrt(x) Return the square root of x. tan(...) tan(x) Return the tangent of x (measured in radians). tanh(...) tanh(x) Return the hyperbolic tangent of x. trunc(...) trunc(x:Real) -> Integral Truncates x to the nearest Integral toward 0. Uses the __trunc__ magic method. DATA e = 2.718281828459045 pi = 3.141592653589793
А здесь - нет ...?¶
In [4]:
help(pydoc)
Help on module pydoc: NAME pydoc - Generate Python documentation in HTML or text for interactive use. FILE c:\users\kiss\anaconda\lib\pydoc.py DESCRIPTION In the Python interpreter, do "from pydoc import help" to provide online help. Calling help(thing) on a Python object documents the object. Or, at the shell command line outside of Python: Run "pydoc <name>" to show documentation on something. <name> may be the name of a function, module, package, or a dotted reference to a class or function within a module or module in a package. If the argument contains a path segment delimiter (e.g. slash on Unix, backslash on Windows) it is treated as the path to a Python source file. Run "pydoc -k <keyword>" to search for a keyword in the synopsis lines of all available modules. Run "pydoc -p <port>" to start an HTTP server on a given port on the local machine to generate documentation web pages. For platforms without a command line, "pydoc -g" starts the HTTP server and also pops up a little window for controlling it. Run "pydoc -w <name>" to write out the HTML documentation for a module to a file named "<name>.html". Module docs for core modules are assumed to be in http://docs.python.org/library/ This can be overridden by setting the PYTHONDOCS environment variable to a different URL or to a local directory containing the Library Reference Manual pages. CLASSES exceptions.Exception(exceptions.BaseException) ErrorDuringImport Doc HTMLDoc TextDoc Helper ModuleScanner Scanner repr.Repr HTMLRepr TextRepr class Doc | Methods defined here: | | docclass = fail(self, object, name=None, *args) | | docdata = fail(self, object, name=None, *args) | | docmodule = fail(self, object, name=None, *args) | | docother = fail(self, object, name=None, *args) | | docproperty = fail(self, object, name=None, *args) | | docroutine = fail(self, object, name=None, *args) | | document(self, object, name=None, *args) | Generate documentation for an object. | | fail(self, object, name=None, *args) | Raise an exception for unimplemented types. | | getdocloc(self, object) | Return the location of module docs or None class ErrorDuringImport(exceptions.Exception) | Errors that occurred while trying to import something to document it. | | Method resolution order: | ErrorDuringImport | exceptions.Exception | exceptions.BaseException | __builtin__.object | | Methods defined here: | | __init__(self, filename, exc_info) | | __str__(self) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes inherited from exceptions.Exception: | | __new__ = <built-in method __new__ of type object> | T.__new__(S, ...) -> a new object with type S, a subtype of T | | ---------------------------------------------------------------------- | Methods inherited from exceptions.BaseException: | | __delattr__(...) | x.__delattr__('name') <==> del x.name | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __getslice__(...) | x.__getslice__(i, j) <==> x[i:j] | | Use of negative indices is not supported. | | __reduce__(...) | | __repr__(...) | x.__repr__() <==> repr(x) | | __setattr__(...) | x.__setattr__('name', value) <==> x.name = value | | __setstate__(...) | | __unicode__(...) | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.BaseException: | | __dict__ | | args | | message class HTMLDoc(Doc) | Formatter class for HTML documentation. | | Methods defined here: | | bigsection(self, title, *args) | Format a section with a big heading. | | classlink(self, object, modname) | Make a link for a class. | | docclass(self, object, name=None, mod=None, funcs={}, classes={}, *ignored) | Produce HTML documentation for a class object. | | docdata(self, object, name=None, mod=None, cl=None) | Produce html documentation for a data descriptor. | | docmodule(self, object, name=None, mod=None, *ignored) | Produce HTML documentation for a module object. | | docother(self, object, name=None, mod=None, *ignored) | Produce HTML documentation for a data object. | | docproperty(self, object, name=None, mod=None, cl=None) | Produce html documentation for a property. | | docroutine(self, object, name=None, mod=None, funcs={}, classes={}, methods={}, cl=None) | Produce HTML documentation for a function or method object. | | escape(self, text) from HTMLRepr | | formattree(self, tree, modname, parent=None) | Produce HTML for a class tree as given by inspect.getclasstree(). | | formatvalue(self, object) | Format an argument default value as text. | | grey(self, text) | | heading(self, title, fgcol, bgcol, extras='') | Format a page heading. | | index(self, dir, shadowed=None) | Generate an HTML index for a directory of modules. | | markup(self, text, escape=None, funcs={}, classes={}, methods={}) | Mark up some plain text, given a context of symbols to look for. | Each context dictionary maps object names to anchor names. | | modpkglink(self, data) | Make a link for a module or package to display in an index. | | modulelink(self, object) | Make a link for a module. | | multicolumn(self, list, format, cols=4) | Format a list of items into a multi-column list. | | namelink(self, name, *dicts) | Make a link for an identifier, given name-to-URL mappings. | | page(self, title, contents) | Format an HTML page. | | preformat(self, text) | Format literal preformatted text. | | repr(self, object) from HTMLRepr | | section(self, title, fgcol, bgcol, contents, width=6, prelude='', marginalia=None, gap=' ') | Format a section with a heading. | | ---------------------------------------------------------------------- | Methods inherited from Doc: | | document(self, object, name=None, *args) | Generate documentation for an object. | | fail(self, object, name=None, *args) | Raise an exception for unimplemented types. | | getdocloc(self, object) | Return the location of module docs or None class HTMLRepr(repr.Repr) | Class for safely making an HTML representation of a Python object. | | Methods defined here: | | __init__(self) | | escape(self, text) | | repr(self, object) | | repr1(self, x, level) | | repr_instance(self, x, level) | | repr_str = repr_string(self, x, level) | | repr_string(self, x, level) | | repr_unicode = repr_string(self, x, level) | | ---------------------------------------------------------------------- | Methods inherited from repr.Repr: | | repr_array(self, x, level) | | repr_deque(self, x, level) | | repr_dict(self, x, level) | | repr_frozenset(self, x, level) | | repr_list(self, x, level) | | repr_long(self, x, level) | | repr_set(self, x, level) | | repr_tuple(self, x, level) class Helper | Methods defined here: | | __call__(self, request=<object object>) | | __init__(self, input=None, output=None) | | __repr__(self) | | getline(self, prompt) | Read one line, using raw_input when available. | | help(self, request) | | interact(self) | | intro(self) | | list(self, items, columns=4, width=80) | | listkeywords(self) | | listmodules(self, key='') | | listsymbols(self) | | listtopics(self) | | showsymbol(self, symbol) | | showtopic(self, topic, more_xrefs='') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | input | | output | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | keywords = {'and': 'BOOLEAN', 'as': 'with', 'assert': ('assert', ''), ... | | symbol = 'u"' | | symbols = {'!=': 'COMPARISON OPERATORS', '"': 'STRINGS', '"""': 'STRIN... | | symbols_ = ("'", "'''", "r'", "u'", '"""', '"', 'r"', 'u"') | | topic = 'STRINGS' | | topics = {'ASSERTION': 'assert', 'ASSIGNMENT': ('assignment', 'AUGMENT... class ModuleScanner | An interruptible scanner that searches module synopses. | | Methods defined here: | | run(self, callback, key=None, completer=None, onerror=None) class Scanner | A generic tree iterator. | | Methods defined here: | | __init__(self, roots, children, descendp) | | next(self) class TextDoc(Doc) | Formatter class for text documentation. | | Methods defined here: | | bold(self, text) | Format a string in bold by overstriking. | | docclass(self, object, name=None, mod=None, *ignored) | Produce text documentation for a given class object. | | docdata(self, object, name=None, mod=None, cl=None) | Produce text documentation for a data descriptor. | | docmodule(self, object, name=None, mod=None) | Produce text documentation for a given module object. | | docother(self, object, name=None, mod=None, parent=None, maxlen=None, doc=None) | Produce text documentation for a data object. | | docproperty(self, object, name=None, mod=None, cl=None) | Produce text documentation for a property. | | docroutine(self, object, name=None, mod=None, cl=None) | Produce text documentation for a function or method object. | | formattree(self, tree, modname, parent=None, prefix='') | Render in text a class tree as returned by inspect.getclasstree(). | | formatvalue(self, object) | Format an argument default value as text. | | indent(self, text, prefix=' ') | Indent text by prepending a given prefix to each line. | | repr(self, x) from TextRepr | | section(self, title, contents) | Format a section with a given heading. | | ---------------------------------------------------------------------- | Methods inherited from Doc: | | document(self, object, name=None, *args) | Generate documentation for an object. | | fail(self, object, name=None, *args) | Raise an exception for unimplemented types. | | getdocloc(self, object) | Return the location of module docs or None class TextRepr(repr.Repr) | Class for safely making a text representation of a Python object. | | Methods defined here: | | __init__(self) | | repr1(self, x, level) | | repr_instance(self, x, level) | | repr_str = repr_string(self, x, level) | | repr_string(self, x, level) | | ---------------------------------------------------------------------- | Methods inherited from repr.Repr: | | repr(self, x) | | repr_array(self, x, level) | | repr_deque(self, x, level) | | repr_dict(self, x, level) | | repr_frozenset(self, x, level) | | repr_list(self, x, level) | | repr_long(self, x, level) | | repr_set(self, x, level) | | repr_tuple(self, x, level) FUNCTIONS allmethods(cl) apropos(key) Print all the one-line module summaries that contain a substring. classify_class_attrs(object) Wrap inspect.classify_class_attrs, with fixup for data descriptors. classname(object, modname) Get a class name and qualify it with a module name if necessary. cli() Command-line interface (looks at sys.argv to decide what to do). cram(text, maxlen) Omit part of a string if needed to make it fit in a maximum length. describe(thing) Produce a short description of the given thing. doc(thing, title='Python Library Documentation: %s', forceload=0) Display text documentation, given an object or a path to an object. getdoc(object) Get the doc string or comments for an object. getpager() Decide what method to use for paging through text. gui() Graphical interface (starts web server and pops up a control window). importfile(path) Import a Python source file or compiled file given its path. isdata(object) Check if an object is of a type that probably means it's data. ispackage(path) Guess whether a path refers to a package directory. ispath(x) locate(path, forceload=0) Locate an object by name or dotted path, importing as necessary. pager = plainpager(text) Simply print unformatted text. This is the ultimate fallback. pathdirs() Convert sys.path into a list of absolute, existing, unique paths. pipepager(text, cmd) Page through text by feeding it to another program. plain(text) Remove boldface formatting from text. plainpager(text) Simply print unformatted text. This is the ultimate fallback. render_doc(thing, title='Python Library Documentation: %s', forceload=0) Render text documentation, given an object or a path to an object. replace(text, *pairs) Do a series of global replacements on a string. resolve(thing, forceload=0) Given an object or a path to an object, get the object and its name. safeimport(path, forceload=0, cache={}) Import a module; handle errors; return None if the module isn't found. If the module *is* found but an exception occurs, it's wrapped in an ErrorDuringImport exception and reraised. Unlike __import__, if a package path is specified, the module at the end of the path is returned, not the package at the beginning. If the optional 'forceload' argument is 1, we reload the module from disk (unless it's a dynamic extension). serve(port, callback=None, completer=None) source_synopsis(file) splitdoc(doc) Split a doc string into a synopsis line (if any) and the rest. stripid(text) Remove the hexadecimal id from a Python object representation. synopsis(filename, cache={}) Get the one-line summary out of a module file. tempfilepager(text, cmd) Page through text by invoking a program on a temporary file. ttypager(text) Page through text on a text terminal. visiblename(name, all=None, obj=None) Decide whether to show documentation on a variable. writedoc(thing, forceload=0) Write HTML documentation to a file in the current directory. writedocs(dir, pkgpath='', done=None) Write out HTML documentation for all modules in a directory tree. DATA __author__ = 'Ka-Ping Yee <ping@lfw.org>' __credits__ = 'Guido van Rossum, for an excellent programming l...erla... __date__ = '26 February 2001' __version__ = '$Revision: 88564 $' help = <pydoc.Helper instance> html = <pydoc.HTMLDoc instance> text = <pydoc.TextDoc instance> VERSION 88564 DATE 26 February 2001 AUTHOR Ka-Ping Yee <ping@lfw.org> CREDITS Guido van Rossum, for an excellent programming language. Tommy Burnette, the original creator of manpy. Paul Prescod, for all his work on onlinehelp. Richard Chamberlain, for the first implementation of textdoc.
Команда help('pydoc') показывает то же самое.
In [7]:
help(help)
Help on _Helper in module site object: class _Helper(__builtin__.object) | Define the builtin 'help'. | This is a wrapper around pydoc.help (with a twist). | | Methods defined here: | | __call__(self, *args, **kwds) | | __repr__(self) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined)
Посты чуть ниже также могут вас заинтересовать
Комментариев нет:
Отправить комментарий