What error is this? AttributeError: 'super' object has no attribute '__getattr__'

6,214 views
Skip to first unread message

Fabio Silva Pedro

unread,
Jul 24, 2019, 8:58:38 AM7/24/19
to Kivy users support
Why does this kind of error occur?

AttributeError: 'super' object has no attribute '__getattr__'

I have this class below:

class ScreenListTasks (Screen):
     def __init __ (self, ** kwargs):
         super () .__ init __ (** kwargs)
         self.ids.List.data = ""

It has a method to clean a RecycleView at startup and when running the script this message appears above.

Grateful to all!

Elliot Garbus

unread,
Jul 24, 2019, 9:54:07 AM7/24/19
to kivy-...@googlegroups.com

         self.ids.List.data

 

Is List the Id of your widget?

 

Button:

    Id:my_button_id

    text: ‘my text here’

 

Would be accessed from python as: self.ids.my_button_id.text

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/1979ff11-a49d-433c-81bf-578c1a80e82c%40googlegroups.com.

 

Fabio Silva Pedro

unread,
Jul 24, 2019, 1:05:50 PM7/24/19
to kivy-...@googlegroups.com
Hi Elliot!
Sorry for that, I did not explain correctly, see the screenshots

List is the same meaning as Listagem in (self.ids.Listagem.data = "")
image.png
image.png
image.png
RecycleView should have its contents erased every time the ListaRV class was called, I also tried to do this using TelaListarTarefas class, but the same error appears. 

What is the meaning of this error?



--
Fábio S. Pedro 
(21) 97569-7573(WhatsApp).

Elliot Garbus

unread,
Jul 24, 2019, 2:14:54 PM7/24/19
to kivy-...@googlegroups.com

There are a few good questions here:

 

….RecycleView should have its contents erased every time the ListaRV class was called…

 

ListRV is a class it is constructed once at initialization.  At initialization it is call in the constructor __init__().

This would be the same as doing it in KV.

ListRV:

    data: my_data

 

Can you describe the user experience you want to achieve?   I’m sure there is another way to get achieve your objective.  As an aside, I’m pretty sure (without looking it up) that the data attribute needs to point to a list of dictionaries.

 

What is the meaning of this error?

__getattr__ is one of the methods in the Python data model.  The details here:  https://docs.python.org/3/reference/datamodel.html

It means that somewhere there is data access with an attribute error and __getattr__() has not been defined.  You can also do a google search for __getattr__ or “Python Magic Methods” to learn more.

 

This might be caused because your are setting data to “”.  You could try setting it to [{}] and see if you get a different result.  More importantly, again I don’t think you will achieve the desired effect with __init__().

 

From the Pyhton docs:

The following methods can be defined to customize the meaning of attribute access (use of, assignment to, or deletion of x.name) for class instances.

object.__getattr__(self, name)

Called when the default attribute access fails with an AttributeError (either __getattribute__() raises an AttributeError because name is not an instance attribute or an attribute in the class tree for self; or __get__() of a name property raises AttributeError). This method should either return the (computed) attribute value or raise an AttributeError exception.

Note that if the attribute is found through the normal mechanism, __getattr__() is not called. (This is an intentional asymmetry between __getattr__() and __setattr__().) This is done both for efficiency reasons and because otherwise __getattr__() would have no way to access other attributes of the instance. Note that at least for instance variables, you can fake total control by not inserting any values in the instance attribute dictionary (but instead inserting them in another object). See the __getattribute__()method below for a way to actually get total control over attribute access.

image.png
image.png
image.png

Fabio Silva Pedro

unread,
Jul 24, 2019, 4:35:47 PM7/24/19
to kivy-...@googlegroups.com
I solved the problem!

I apologize to you, sometimes I put the craziest and most meaningless things in unsuccessful attempts to solve problems!

In fact what I tried to do was not feasible! and i read the documentation of other programs and i discovered the "on_pre_enter".

So the line of code I needed was:

class ScreenListTasks (Screen):
    def on_pre_enter (self, * args):
        self.ids.List.data = ""

Now, every time the app returns the screen from home menu and back again to the list, it is automatically clears.

Thanks Elliot for your help again!

Elliot Garbus

unread,
Jul 24, 2019, 6:23:22 PM7/24/19
to kivy-...@googlegroups.com
Glad to hear you got it working!

Sent from my iPhone
Reply all
Reply to author
Forward
0 new messages