Writing Class Browser etc for Python

Michael Hudson mwh at python.net
Wed Aug 7 10:42:42 EDT 2002


jglueck at vol.at (Bernhard Glück) writes:

> Hi
> 
> I am currently investigating if i can implement Python2.2 as our
> primary scripting language for our new application/multimedia
> architecture. I am Python newbie, so please bear with me ( I am only
> concerned with the API for Extending/Embedding Python in C/C++ )

Often the easiest (or only) way to do want you want is to call the
Python API from C.  Fortunately this is pretty easy.

> I need to know if and how it would be possible to write some sort of
> class browser in C++.
> 
> In our architecture there are only "Actor" classes which "do
> something" in the world. All classes derive from this base class in
> C++. Now i want to extend this class hierarchy with python classes so
> that it is allowed to derive from any Actor derived C++ class in
> Python too. This should not be a real problem. However  all Actor
> derived classes need to be inspected and instantiated in our Editor
> tool. Having a class browser of the C++ classes is very easy with out
> RTTI Type system , however now i also need to know ALL Python classes
> currently in memory which derive directly or indirectly from the C++
> Actor, as well as know their methods and variables.

If these are new-style class you're creating, then I think

PyEval_CallMethod(ActorClass, "__subclasses__", "");

and a dab of recursion is your friend...

Cheers,
M.

-- 
  The Oxford Bottled Beer Database heartily disapproves of the 
  excessive consumption of alcohol.  No, really.
                        -- http://www.bottledbeer.co.uk/beergames.html
                           (now sadly gone to the big 404 in the sky)



More information about the Python-list mailing list