Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-04-06 06:52:10


----- Original Message -----
From: "Pearu Peterson" <boost_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, April 06, 2001 3:31 AM
Subject: [boost] Boost.Python special methods

>
> Hi!
>
> Question:
> Is is it possible to define special methods other than specified in
> the table of Automatically Wrapped Methods?
>
> I really miss methods like __contains__, __lt__, __gt__, __le__, __eq__,
> __ne__, __ge__. And defining them, for example, as

Considering that the latter 6 functions aren't even mentioned in the current
Python documentation, don't you think it's a bit early to ask for them from
Boost.Python? ;-)

(http://search.python.org/query.html?col=pydocs&ht=0&qp=&qt=__ge__&qs=&qc=&p
w=100%25&ws=0&qm=0&st=1&nh=10&lk=1&rf=0&rq=0&si=1 shows no hits)

> lst_class.def(&basic_w::has_w, "__contains__");
>
> has wrong effect in Python:
>
> >>> l=lst(1,2,3)
> >>> l
> lst([ex(1), ex(2), ex(3)])
> >>> 2 in l
> 0 # should be 1!!!
> >>> l.__contains__ (2)
> 1

__contains__ appears to be a Python 2.0 feature for which we haven't yet
written the support. If you'd like to add a feature request (or better yet,
a patch) to the sourceforge tracking system
(http://sourceforge.net/tracker/?group_id=7586), it would be much
appreciated.

Thanks,
Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk