A newbie to Python question.

Andrew M. Kuchling akuchlin at cnri.reston.va.us
Thu May 6 17:06:16 EDT 1999


Jr. King writes:
>question.  I know java and C++ are different, but with jPython you tell it
>to import your class and what not and the interpreter can use those classes
>like a regular old java app.  If I were to put my c++ (WIN32) classes in a
>dll can python still access variables in the classes that are contained in
>the dll like it does with java classes.  

	Unfortunately, no; this is perhaps the largest advantage
JPython has over CPython, and it's a really cool ability.  Java
provides an interface called the Reflection API that lets code examine
classes, determine method signatures (this method takes an integer and
a string as input, and returns a boolean), and other meta-information.
C and C++ don't have any such interface for getting information about
functions and methods; the most you can do is get the address of a
function, and that's about it.  (Unless ANSI C++ adds something novel
that I haven't heard of?)

	The closest you can get in C++ is to use something like COM,
which is the only Microsoft technology that I wish we had on Unix.  If
you drop a new COM component onto a Windows system, PythonWin can
automatically access it, without writing any C++ interface code.
Windows people can tell you more about that.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
I won't eat any cereal that doesn't turn the milk purple.
    -- Bill Watterson, _The Authoritative Calvin and Hobbes_





More information about the Python-list mailing list