ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
[C++-sig] Re: Static, again...
by Mike Rovner other posts by this author
Nov 15 2002 1:43AM messages near this date
RE: [C++-sig] Static, again... | Re: [C++-sig] Re: Static, again...
"Hugo van der Merwe" <hugo@[...].za>  wrote in message
news:20021114053940.GB16542@[...]..
>  On Wed, Nov 13, 2002 at 08:19:53AM -0500, David Abrahams wrote:
>  > Hugo van der Merwe <hugo@[...].za> writes:
>  >
>  > Yes, but I'll leave it as an "exercise for the reader". Properties are
>  > a Python 2.2 thing, not a Boost.Python feature. Try it in pure
>  > Python. If you can get that to work, you can probably get it to work
>  > in Boost.Python. Hint: you'll need a proxy class.

If I understand correctly
Pythons
  x.a[3]=1
will go through
__setitem__(__getattr__(x,"a"), 3, 1)

If so, it shall be easy (untested):

struct proxy {
  GetItem();
  SetItem():
};
struct X {
  proxy a;
}

class_<proxy> ("proxy")
  .def("__getitem__", &proxy::GetItem)
  .def("__setitem__", &proxy::SetItem)
;

class_<X> ("X")
  .add_property("a", &X::a)
;

Right?





_______________________________________________
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved