This section describes modeling devices with Python. There are currently three ways of modeling with Python:
pyobj module (ConfObject class), which is documented in the
Modeling with Python (pyobj) section.confclass class, which is documented in the Modeling with Python
(confclass) section.empty-device-python module.In the choice between pyobj and confclass:
pyobj is slightly more feature complete, but relies on inheritance to add
attributes and interfaces, which means that subclasses for these needs to be
added.confclass is the newest of the two, and has a slightly more condensed
syntax, where attributes and interfaces are added using hierarchical
decorators. The missing functionality (see below) will be addressed in future
releases.This is a short high-level functionality comparison between pyobj and
confclass:
| Aspect/Property | pyobj | confclass |
|---|---|---|
| Documentation | good | fair, but lacks api-documentation |
| Attributes | supported | supported |
| Ports | supported | supported |
| Class attributes | supported | not supported |
| Events | supported | not supported |
| Inheritance | supported | supported |
| Info and Status commands | automatically added | not automatically added, but can be added with decorators (see 16.2.8) |
Information on how to port a pyobj class to confclass, see section
16.3.
The API you use to write components is based on pyobj (see StandardComponent). There is no plan to implement a
confclassbased variant of this API as the component system is being phased out. The recommendation is to instead use blueprints (see comparison and porting sections).