A problem with some OO code.

Diez B. Roggisch deets at nospam.web.de
Sat Feb 4 09:32:16 EST 2006


> AttributeError: 'Obj' object has no attribute
> '_Object__ls_demanded_links'
> --------------------------------------------------
> 
> Perhaps I'll explain what's going on there. First, the objects' manager
> is created, and then also some objects are created. After doing that,
> the object called "objA" demands a new link to the other object, called
> "objB" (this is the line 81 in the error message above). As the result,
> the "demandNewLink" method of the object "objA" is called. This method
> calls the "_makeNewLink" method of the objects' manager, and this
> method calls the "_makeLinkSafe" method of the object, that demanded a
> new link. The last method, called "__makeNewLink" (so this is a
> so-called private method), is called then. This last method is supposed
> to check if the link was really demanded and then make it "safe" by
> placing the information about this link in the proper dictionary
> (__ls_existing_links).
> 
> All these methods are the methods of the Object class (defined in
> PyObject.py), not of the Obj class (defined in test.py). According to
> my knowledge about the OO programming Python should be able to realize,
> that the so-called private fields, that are being referred from these
> Object class methods, are the private fields of the *Obj class
> instance*, not of the *Object class one*.

I didn't find any place where you create your __ls_demanded_links-list. 
So - how do you expevct it to be found, __-semantics or not?

But I _did_ find a self.__ls_demandedLinks. So I guess you got confused 
in your variable names.


After changing that, I got some other errors.

So basically this boils down to some simple spelling errors. You migt 
want to think about using pychecker or pylint or both, and a 
auto-completion-capable editor like eric or (x)emacs.

Diez



More information about the Python-list mailing list