[C++-sig] Re: replacing object constructors by factories

David Abrahams dave at boost-consulting.com
Fri Jan 30 23:19:16 CET 2004


Stefan Seefeld <stefan.seefeld at orthosoft.ca> writes:

> hi there,
>
> I'm exposing classes to python which are not directly
> instantiable via constructors, but via factories.
>
> However, I'd like to be able to instantiate class 'Foo'
> by
>
> foo = Foo()
>
>
> nonetheless, I'v managed to do that by defining 'Foo'
> as a global Function returning a 'Foo' instance.
> But as soon as that is done, python obviously reports
> 'Foo' as a function, not a 'class'.
>
> Are there other ways provide 'user hooks' as constructors ?

See http://www.boost-consulting.com/boost/libs/python/doc/v2/make_function.html#make_constructor-spec

I know that isn't very clear, but along with 
http://www.boost-consulting.com/boost/libs/python/test/injected.cpp
it should get you there.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list