|
Boost : |
From: Barry Scott (barry_at_[hidden])
Date: 2000-10-16 15:16:51
David,
I finally got some time to play with py_cpp.
There are three problems I found while playing around with demo.dll.
1. __dict__ is not working for classes derived from py_cpp classes
2. __doc__ for functions defined in the derived class do not work
3. dir(class) does not list the functions available in the class
(See the code of dir in the Python sources for the names of the
secret names it access via getattr. CXX has support for some
of them.)
BArry
Here is a test that I think should run without error.
-----------------test_py_cpp.py----------------------
import sys
import demo
class DerivedFromFoo(demo.Foo):
def __init__(self):
demo.Foo.__init__( self, 1 )
def fred(self):
'Docs for DerivedFromFoo.fred'
print 'Barry.fred'
class Base:
i_am_base = 'yes'
def fred(self):
'Docs for Base.fred'
pass
class DerivedFromBase(Base):
i_am_derived_from_base = 'yes'
def fred(self):
'Docs for DerivedFromBase.fred'
pass
print 'Testing DerivedFromFoo'
print '----------------------'
df = DerivedFromFoo()
print 'dir(df):',dir(df)
print 'dir(DerivedFromFoo):',dir(DerivedFromFoo)
try:
print 'df.__dict__:',df.__dict__
except:
type, value, traceback_obj = sys.exc_info()
print '\nError: Type',type,'value',value
try:
print 'df.fred.__doc__:',df.fred.__doc__
except:
type, value, traceback_obj = sys.exc_info()
print '\nError: Type',type,'value',value
print
print 'Testing DerivedFromBase'
print '-----------------------'
db = DerivedFromBase()
print 'dir(db):',dir(db)
print 'dir(DerivedFromBase):',dir(DerivedFromBase)
print 'db.__dict__:',db.__dict__
print 'db.fred.__doc__:',db.fred.__doc__
-----------------test_py_cpp.py----------------------
-----------------Output example----------------------
Python 1.5.2 (#0, May 22 2000, 17:17:30) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import test_py_cpp
Testing DerivedFromFoo
----------------------
dir(df): []
dir(DerivedFromFoo): []
df.__dict__:
Error: Type exceptions.AttributeError value __dict__
df.fred.__doc__:
Error: Type exceptions.AttributeError value 'class py::BoundFunction' object has no attribute '__doc__'
Testing DerivedFromBase
-----------------------
dir(db): []
dir(DerivedFromBase): ['__doc__', '__module__', 'fred', 'i_am_derived_from_base']
db.__dict__: {}
db.fred.__doc__: Docs for DerivedFromBase.fred
>>>
-----------------Output example----------------------
> -----Original Message-----
> From: c++-sig-admin_at_[hidden] [mailto:c++-sig-admin_at_[hidden]]On
> Behalf Of David Abrahams
> Sent: 16 October 2000 03:18
> To: Xavier Defrang; Ullrich Koethe; Prabhu Ramachandran; Niklas
> Blomberg; Chuck_Ingold_at_[hidden]; c++-sig_at_[hidden];
> boost_at_[hidden]; Anton Gluck; Ralf W. Grosse-Kunstleve
> Subject: [C++-SIG] py_cpp update
>
>
> An update of py_cpp has been posted to
> http://people.ne.mediaone.net/abrahams/downloads/py_cpp.html.
>
> The main focus of this update is revised and expanded documentation (a work
> still in progress). Changes to the code were minimal.
>
> The boost review period for py_cpp ends 19 Oct. I hope that if you are
> interested in this library you will join the boost mailing list at
> www.egroups.com and participate in the open-source feedback loop.
>
> Thanks,
> Dave
>
>
>
> _______________________________________________
> C++-SIG maillist - C++-SIG_at_[hidden]
> http://www.python.org/mailman/listinfo/c++-sig
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk