|
Boost : |
From: Prabhu Ramachandran (prabhu_at_[hidden])
Date: 2000-10-31 13:20:18
hi,
>>>>> "David" == David Abrahams <abrahams_at_[hidden]> writes:
David> See
David> http://people.ne.mediaone.net/abrahams/downloads/py_cpp.html.
David> New features: 1. support for non-const reference parameters
David> to constructors 2. support for special member attributes
David> __doc__, __class__, __bases__, etc. 3. support for
Ummm. A few problems I found with the latest code base. I have a
small test program with classes named A and B (it is really a test :)
class A has a single virtual method - func(const int x) const
class B : public A and has a method - func1(const int x) const
I wrapped this and compiled it into a module called test. And in
python I get the following.
>>> from test import *
>>> dir (A)
['__init__', 'func', 'func1']
# This should not show func1.
>>> dir (B)
['__doc__', '__module__']
# This is not good. :(
>>> B.__bases__
(<Q22pyt5Class1ZQ22py17ExtensionInstance object at 807d644>,)
# Is this Ok? I dont know. Maybe.
>>> dir (B.__bases__[0])
['__init__', 'func', 'func1']
# Ok. Atleast this is consistent.
>>> b = B ()
>>> b.func (1)
A::func : t = 1
# Ok! this is correct. I was able to call A's func.
>>> b.__class__
<Q22pyt5Class1ZQ22py17ExtensionInstance object at 807d90c>
# Correct?
>>> a = A ()
>>> dir (a.__class__)
['__init__', 'func', 'func1']
# Ok. consistent.
The reason I am particular about these attributes is because there is
some pretty useful stuff that one can do using these. I use this
routinely to generate a pipeline browser for VTK. Is it also possible
to get the number of arguments that a function expects?? Sorry to
pester you with obscure things like this. :)
How does one set the __doc__ ?? Could the other special attributes
__dict__ etc. be added or are they irrelevant (I dont use them, I do
use dir, __bases__ and __class__). For reference on the special
attributes look here
http://www.pythonlabs.com/pub/www.python.org/doc/current/lib/specialattrs.html
David> multiple inheritance from py_cpp extension classes and
David> regular python classes.
Wow!
prabhu
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk