Can't override class |__new__
Lie Ryan
lie.1296 at gmail.com
Thu Mar 5 06:59:59 EST 2009
jelle feringa wrote:
> 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()
You're not creating Facet object here, not even Polyhedron.Facet.
> 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?
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,
>
> -jelle
>
More information about the Python-list
mailing list