Is this an attribute?

Steven D'Aprano steve at pearwood.info
Tue Jan 19 19:03:22 EST 2016


On Wed, 20 Jan 2016 07:19 am, Robert wrote:

> Hi,
> 
> When I read a code snippet below, I find I don't know what
> 'self.framelogprob' is on the child class.
[...]
> On Python web, it says that things after dot, such as a class name, are
> attributes. From this definition, 'framelogprob' is an attribute. But when
> I run the command on Canopy:
> 
> h.framelogprob
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call
> last) <ipython-input-19-970ee2f3402c> in <module>()
> ----> 1 h.framelogprob
> 
> AttributeError: 'StubHMM' object has no attribute 'framelogprob'
> 
> 
> it doesn't recognize it as an attribute. What is wrong with my
> understanding?


Just because you ask "give me attribute foo" doesn't mean attribute foo
exists. I can use attribute syntax to look up an attribute that doesn't
exist, and Python will raise AttributeError.


The question is, perhaps that attribute gets created elsewhere. You would
need to read all the source code, or read the documentation, to see where
and under what circumstances StubHMM objects gain a framelogprob attribute.



-- 
Steven




More information about the Python-list mailing list