Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > implicit conversion

Reply
Thread Tools

implicit conversion

 
 
Benjamin Schmeling
Guest
Posts: n/a
 
      01-31-2005
Hi,

I am working on exposing a bigint class to python. Now I've got the
problem that methods which take an bigint as
an parameter do not accept Python longs.

For example:
import _PythonLiDIA
x=123L;
c=_PythonLiDIA.bigint();
_PythonLiDIA.gcd(c,x);


Traceback (most recent call last):
File "test.py", line 132, in ?
_PythonLiDIA.gcd(a,x);
Boost.Python.ArgumentError: Python argument types in
_PythonLiDIA.gcd(bigint, long)
did not match C++ signature:
gcd(LiDIA::bigint, LiDIA::bigint)

I don't know how to achieve implicit conversion at this point, turning an
long automatically into an bigint. The other way round, turning an bigint
into long can be realized by defining __long__.

Can someone help me please?

Benjamin


 
Reply With Quote
 
 
 
 
Alex Martelli
Guest
Posts: n/a
 
      01-31-2005
Benjamin Schmeling <(E-Mail Removed)> wrote:
...
> I don't know how to achieve implicit conversion at this point, turning an
> long automatically into an bigint. The other way round, turning an bigint
> into long can be realized by defining __long__.


Perhaps adding to your bigint class a constructor (not declared as
``explicit'', if you're coding C++) which accepts as its argument a
python long might help...?


Alex
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with implicit conversion Boris C++ 3 08-26-2004 02:03 PM
Implicit/explicit conversion al C++ 2 01-07-2004 10:18 AM
Implicit conversion is evil? Russell Reagan C++ 2 10-27-2003 04:44 PM
Question on additional decimals in implicit conversion Jacob Java 7 10-03-2003 10:23 PM
implicit vs. explicit type conversion for string vs. (char *) dmoos AT esigma-systems DOT de C++ 2 06-26-2003 04:32 PM



Advertisments