Can't override class |__new__

jelle feringa jelleferinga at gmail.com
Thu Mar 5 03:27:12 EST 2009


Hi,

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()
p.make_triangle()

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?
Can I perhaps alter it using  the new module or __new__ method?

Many thanks in advance,

-jelle




More information about the Python-list mailing list