Dynamic annotations

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic annotations

Mathias Millet
Hello,
I am trying to dynamically access annotations of indviduals and classes
(i.e. use something like
my_indiv[var]
where var is a string containing the name of an annotation).

I found a workaround working with individuals :

my_indiv.__getattr__(var) seems to work,

but this doesn't work with classes.

Do you know if I can get through this ?

Thanks, Mathias
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic annotations

Jiba
Administrator
Hello,

You should use getattr:

        getattr(my_class, var)

(__getattr__ works for individuals but not classes, because on a class, you get the class function that should be applied on individuals, not the metaclass bound method).

Best regards,
Jean-Baptiste Lamy
MCF HDR, Laboratoire LIMICS, Université Paris 13