property for class objects

S

Steve Menard

As par of JPype, I find that I have to brifge Java static members into
class attributes.

I am using a metaclass to dynamically create a Python class for every
Java type encountered. Instance variables were handled by adding a
property(get, set) to the class's dictionary.

Now static members are giving me a headache. I cannot use "property" for
them, because properties are for instances only.

What I am currently doing is adding a __getattr__ and a __setattr__
methods to the metaclass, which is called when a class attribute is
requested but not found in the class' dict.

This works fine exact it does not walk the inheritance tree to find
static members defined in base classes. I am currently adding up all the
names in every class. This "works", however it is misleading when you do
a dir() of the class.

Does anyone have an idea how to implement "classproperty" ?

Thanks in advance for any help,

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,211
Messages
2,571,092
Members
47,693
Latest member
david4523

Latest Threads

Top