Confusing on bool data object or class function?

Steven D'Aprano steve at pearwood.info
Sun Jan 10 22:17:01 EST 2016


On Mon, 11 Jan 2016 12:57 pm, Robert wrote:

> Hi,
> 
> When I use an on line code snippet, see below please, I find that
> 'converged' in class ConvergenceMonitor is seen as a data.

That is because converged is a property. That makes it be seen as data.

>     @property
>     def converged(self):


Properties are computed attributes. Although they have a function deep
inside them, to perform the computation, they are seen from the outside as
data attributes.

See the documentation for "property" for more information, and google
for "descriptor" for the underlying mechanism that allows this to work.
(Warning: descriptors are considered very advanced material.)



-- 
Steven




More information about the Python-list mailing list