Re: [C++-sig] Static, again...
by Hugo van der Merwe other posts by this author
Nov 13 2002 6:51AM messages near this date
Re: [C++-sig] Static, again...
|
Re: [C++-sig] Static, again...
> Unfortunately, no. That would be cool, though, wouldn't it? I'm
> pretty sure you can do this after you define class_<Settings>, though:
>
> // Note no leading dot.
> def("Settings", &Settings::GetInstance
> , return_value_policy<reference_existing_object>());
>
> This will replace the class in the module by a function called
> Settings that gets the instance.
Yes, that worked beautifully! Now I just do (in Python):
Settings().detailThreshold = 10
Settings().verbose = true
Just found it hard to decide whether I should keep the Python wrapper
as close as possible to the C++ library and use "SetVerbose" and
"GetVerbose", or whether to use Boost.Python's really nifty
properties. Well, I couldn't resist! ;)
Do properties currently only handle straight forward single parameter
"setters"? How difficult would it be to allow it to do two parameters,
with e.g. "object.property[5] = 10"? (Or can it do that already?)
> I think that's right. However, I wonder if we should change the
> __init__ function that you get from no_init to be a no-op unless the
> Python class actually has the same type as the abstract base...
Sounds like an idea ...
Thanks again!
Hugo van der Merwe
_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
Thread:
Hugo van der Merwe
Scott A. Smith
David Abrahams
Scott A. Smith
Nicodemus
Scott A. Smith
Mike Rovner
David Abrahams
David Abrahams
Hugo van der Merwe
Hugo van der Merwe
David Abrahams
Hugo van der Merwe
David Abrahams
|