diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/python~3.12/library%2Fpyclbr.html | |
new repository
Diffstat (limited to 'devdocs/python~3.12/library%2Fpyclbr.html')
| -rw-r--r-- | devdocs/python~3.12/library%2Fpyclbr.html | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/devdocs/python~3.12/library%2Fpyclbr.html b/devdocs/python~3.12/library%2Fpyclbr.html new file mode 100644 index 00000000..3741e140 --- /dev/null +++ b/devdocs/python~3.12/library%2Fpyclbr.html @@ -0,0 +1,57 @@ + <span id="pyclbr-python-module-browser-support"></span><h1>pyclbr — Python module browser support</h1> <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/pyclbr.py">Lib/pyclbr.py</a></p> <p>The <a class="reference internal" href="#module-pyclbr" title="pyclbr: Supports information extraction for a Python module browser."><code>pyclbr</code></a> module provides limited information about the functions, classes, and methods defined in a Python-coded module. The information is sufficient to implement a module browser. The information is extracted from the Python source code rather than by importing the module, so this module is safe to use with untrusted code. This restriction makes it impossible to use this module with modules not implemented in Python, including all standard and optional extension modules.</p> <dl class="py function"> <dt class="sig sig-object py" id="pyclbr.readmodule"> +<code>pyclbr.readmodule(module, path=None)</code> </dt> <dd> +<p>Return a dictionary mapping module-level class names to class descriptors. If possible, descriptors for imported base classes are included. Parameter <em>module</em> is a string with the name of the module to read; it may be the name of a module within a package. If given, <em>path</em> is a sequence of directory paths prepended to <code>sys.path</code>, which is used to locate the module source code.</p> <p>This function is the original interface and is only kept for back compatibility. It returns a filtered version of the following.</p> </dd> +</dl> <dl class="py function"> <dt class="sig sig-object py" id="pyclbr.readmodule_ex"> +<code>pyclbr.readmodule_ex(module, path=None)</code> </dt> <dd> +<p>Return a dictionary-based tree containing a function or class descriptors for each function and class defined in the module with a <code>def</code> or <code>class</code> statement. The returned dictionary maps module-level function and class names to their descriptors. Nested objects are entered into the children dictionary of their parent. As with readmodule, <em>module</em> names the module to be read and <em>path</em> is prepended to sys.path. If the module being read is a package, the returned dictionary has a key <code>'__path__'</code> whose value is a list containing the package search path.</p> </dd> +</dl> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.7: </span>Descriptors for nested definitions. They are accessed through the new children attribute. Each has a new parent attribute.</p> </div> <p>The descriptors returned by these functions are instances of Function and Class classes. Users are not expected to create instances of these classes.</p> <section id="function-objects"> <span id="pyclbr-function-objects"></span><h2>Function Objects</h2> <p>Class <code>Function</code> instances describe functions defined by def statements. They have the following attributes:</p> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Function.file"> +<code>Function.file</code> </dt> <dd> +<p>Name of the file in which the function is defined.</p> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Function.module"> +<code>Function.module</code> </dt> <dd> +<p>The name of the module defining the function described.</p> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Function.name"> +<code>Function.name</code> </dt> <dd> +<p>The name of the function.</p> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Function.lineno"> +<code>Function.lineno</code> </dt> <dd> +<p>The line number in the file where the definition starts.</p> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Function.parent"> +<code>Function.parent</code> </dt> <dd> +<p>For top-level functions, None. For nested functions, the parent.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.7.</span></p> </div> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Function.children"> +<code>Function.children</code> </dt> <dd> +<p>A dictionary mapping names to descriptors for nested functions and classes.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.7.</span></p> </div> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Function.is_async"> +<code>Function.is_async</code> </dt> <dd> +<p><code>True</code> for functions that are defined with the <code>async</code> prefix, <code>False</code> otherwise.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.10.</span></p> </div> </dd> +</dl> </section> <section id="class-objects"> <span id="pyclbr-class-objects"></span><h2>Class Objects</h2> <p>Class <code>Class</code> instances describe classes defined by class statements. They have the same attributes as Functions and two more.</p> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Class.file"> +<code>Class.file</code> </dt> <dd> +<p>Name of the file in which the class is defined.</p> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Class.module"> +<code>Class.module</code> </dt> <dd> +<p>The name of the module defining the class described.</p> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Class.name"> +<code>Class.name</code> </dt> <dd> +<p>The name of the class.</p> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Class.lineno"> +<code>Class.lineno</code> </dt> <dd> +<p>The line number in the file where the definition starts.</p> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Class.parent"> +<code>Class.parent</code> </dt> <dd> +<p>For top-level classes, None. For nested classes, the parent.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.7.</span></p> </div> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Class.children"> +<code>Class.children</code> </dt> <dd> +<p>A dictionary mapping names to descriptors for nested functions and classes.</p> <div class="versionadded"> <p><span class="versionmodified added">New in version 3.7.</span></p> </div> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Class.super"> +<code>Class.super</code> </dt> <dd> +<p>A list of <code>Class</code> objects which describe the immediate base classes of the class being described. Classes which are named as superclasses but which are not discoverable by <a class="reference internal" href="#pyclbr.readmodule_ex" title="pyclbr.readmodule_ex"><code>readmodule_ex()</code></a> are listed as a string with the class name instead of as <code>Class</code> objects.</p> </dd> +</dl> <dl class="py attribute"> <dt class="sig sig-object py" id="pyclbr.Class.methods"> +<code>Class.methods</code> </dt> <dd> +<p>A dictionary mapping method names to line numbers. This can be derived from the newer children dictionary, but remains for back-compatibility.</p> </dd> +</dl> </section> <div class="_attribution"> + <p class="_attribution-p"> + © 2001–2023 Python Software Foundation<br>Licensed under the PSF License.<br> + <a href="https://docs.python.org/3.12/library/pyclbr.html" class="_attribution-link">https://docs.python.org/3.12/library/pyclbr.html</a> + </p> +</div> |
