Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`python`.`modules`.`PythonModule``

class documentation

`class PythonModule(_ModuleIteratorHelper): (source)`

View In Hierarchy

Representation of a module which could be imported from sys.path.

Method | `__eq__` | PythonModules with the same name are equal.
Method | `__init__` | Create a PythonModule. Do not construct this directly, instead inspect a PythonPath or other PythonModule instances.
Method | `__repr__` | Return a string representation including the module name.
Method | `isLoaded` | Determine if the module is loaded into sys.modules.
Method | `isPackage` | Returns true if this module is also a package, and might yield something from iterModules.
Method | `iterAttributes` | List all the attributes defined in this module.
Method | `load` | Load this module.
Method | `walkModules` | Similar to `iterModules`, this yields self, and then every module in my package or entry, and every submodule in each package or entry.
Instance Variable | `filePath` | a FilePath-like object which points to the location of this module.
Instance Variable | `name` | the fully qualified python name of this module.
Instance Variable | `parentPath` | Undocumented
Instance Variable | `pathEntry` | a `PathEntry` instance which this module was located from.
Method | `_getEntry` | Implement in subclasses to specify what path entry submodules will come from.
Method | `_packagePaths` | Yield a sequence of FilePath-like objects which represent path segments.
Method | `_subModuleName` | submodules of this module are prefixed with our name.

Inherited from `_ModuleIteratorHelper`:

Method | `__getitem__` | Retrieve a module from below this path or package.
Method | `__iter__` | Implemented to raise NotImplementedError for clarity, so that attempting to loop over this object won't call __getitem__.
Method | `iterModules` | Loop over the modules present below this entry or package on PYTHONPATH.

def __eq__(self, other): (source)

PythonModules with the same name are equal.

Parameters
other:`object` | Undocumented
Returns
`bool` | Undocumented

def __init__(self, name, filePath, pathEntry): (source)

Create a PythonModule. Do not construct this directly, instead inspect a PythonPath or other PythonModule instances.

Parameters
name | see ivar
filePath | see ivar
pathEntry | see ivar

def __repr__(self): (source)

Return a string representation including the module name.

Returns
`str` | Undocumented

def isLoaded(self): (source)

Determine if the module is loaded into sys.modules.

Returns
a boolean: true if loaded, false if not.

def isPackage(self): (source)

Returns true if this module is also a package, and might yield something from iterModules.

def iterAttributes(self): (source)

List all the attributes defined in this module.

Note: Future work is planned here to make it possible to list python attributes on a module without loading the module by inspecting ASTs or bytecode, but currently any iteration of PythonModule objects insists they must be loaded, and will use inspect.getmodule.

Returns
a generator yielding PythonAttribute instances describing the attributes of this module.
Raises
`NotImplementedError` | if this module is not loaded.

def load(self, default=_nothing): (source)

Load this module.

Parameters
default | if specified, the value to return in case of an error.
Returns
types.ModuleType. | a genuine python module.
Raises
`Exception` | Importing modules is a risky business; the erorrs of any code run at module scope may be raised from here, as well as ImportError if something bizarre happened to the system path between the discovery of this PythonModule object and the attempt to import it. If you specify a default, the error will be swallowed entirely, and not logged.

def walkModules(self, importPackages=False): (source)
overrides `twisted.python.modules._ModuleIteratorHelper.walkModules`

Similar to `iterModules`, this yields self, and then every module in my package or entry, and every submodule in each package or entry.

In other words, this is deep, and `iterModules` is shallow.

filePath = (source)

a FilePath-like object which points to the location of this module.

name = (source)

the fully qualified python name of this module.

parentPath = (source)

Undocumented

pathEntry = (source)

a `PathEntry` instance which this module was located from.

def _getEntry(self): (source)
overrides `twisted.python.modules._ModuleIteratorHelper._getEntry`

Implement in subclasses to specify what path entry submodules will come from.

Returns
a PathEntry instance.

def _packagePaths(self): (source)
overrides `twisted.python.modules._ModuleIteratorHelper._packagePaths`

Yield a sequence of FilePath-like objects which represent path segments.

def _subModuleName(self, mn): (source)
overrides `twisted.python.modules._ModuleIteratorHelper._subModuleName`

submodules of this module are prefixed with our name.