getattr
returns the value of an attribute.
dir
returns the list of attributes for an object.
They both work well out of the box, but if the class defines the magic methods __getattr__
and __dir__
you could get unexpected results.
It’s common for an object to define __getattr__
, so you can use it as if it had attributes that are not defined in the class. It’s less common for that object to define and maintain __dir__
. Sometimes the lack of __dir__
magic method is a message for you, the developer is trying to tell you “please don’t mess up with this”. And sometimes the __getattr__
needs to try to get the requested attribute, doesn’t know the list of available attributes.
I don’t know why app_tables
doesn’t give you the list.
I have an app that allows to pick a table, but I have also a manually maintained table with the list of pickable tables.
Another solution is to go down this path, but it’s going to be tough: Programmatically access data about my Anvil apps - #4 by stefano.menci