Can't override class |__new__
lie.1296 at gmail.com
Thu Mar 5 12:59:59 CET 2009
jelle feringa wrote:
> I'm working with a C++ module ( CGAL, comp.geom. with exact arithmic )
> and am having troubles finding a way to override how the modules returns
> objects. What I'm trying to do is to extend the Facet class, but when I try
> to use my version of the class, the parent class is still being returned
> import CGAL
> CGAL.Facet = OtherFacet
> CGAL.Polyhedron.Facet = OtherFacet
> p = CGAL.Polyhedron_3()
You're not creating Facet object here, not even Polyhedron.Facet.
> for f in p.facets:
> print f
> <CGAL.Polyhedron.Facet object at 0x47ed50>
> # Here I was expecting a OtherFacet object
> Is there a way of getting around this, or is this behaviour hardcoded in the
> C++ module?
I think so. External module written in C/C++ is often statically linked.
> Can I perhaps alter it using the new module or __new__ method?
> Many thanks in advance,
More information about the Python-list