|
Re: registering simple conversions from/to python: msg#00233python.c++
"Brett Calcott" <brett.calcott@xxxxxxxxxxxxxxx> writes: > I'd like to pythonise my classes a little by allowing tuples to be passed to > and from the data values. > > In python in would look something like this: > > class C(object): > def __init__(self, x=0.0, y=0.0): > self.x = x > self.y = y > > def get_xy(self): > return self.x, self.y > > def set_xy(self, xy): > self.x, self.y = xy > > xy = property(get_xy, set_xy) > > > I guess I would start by created a pair<x, x> object, and then register > inward and outward conversions for it. > > Is there a simple recipe for registering these conversions? Brett, I'm sorry, I can't tell what you're trying to do. Could you please show an example of your C++ class and how you'd like to use it from Python? Thanks, -- Dave Abrahams Boost Consulting www.boost-consulting.com |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Recent changes to FAQ: 00233, David Abrahams |
|---|---|
| Next by Date: | Re: Re: Mac OS 10 & type_with_alignment.hpp: 00233, Ralf W. Grosse-Kunstleve |
| Previous by Thread: | Re: Re: registering simple conversions from/to pythoni: 00233, Ralf W. Grosse-Kunstleve |
| Next by Thread: | Re: registering simple conversions from/to python: 00233, Brett Calcott |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |