Python to C++ translation?

Jorgen Grahn jgrahn-nntq at
Sun Aug 7 09:47:14 CEST 2005

On 18 Jul 2005 14:39:22 -0700, Mangabasi <mangabasi at> wrote:
> Hi there,
> I need to translate the following code (rather something similar) to
> C++.  I have been studying C++ for the last two days but I could not
> find an easy way to do the following Python snippet.
> How do I make this work for
> C c2 = C(b, a)
> as well?
> Thank you in advance, I know this is somehow offtopic in the Python
> group but I would not dare asking this in the C++ groups.

In general, it is not a good idea to try to make a straight translation from
one language to another, especially between a very dynamic one like Python
to a very static one like C++ [1].  You might be able to do a straight
translation of some of the design, but soon you would find yourself working
against the language and missing out on its good features.

I think you'd be better off starting from scratch. (Or maybe not really from
scratch; having done a working version of the program once and maybe having
working tests is worth a lot.)


[1] You might find C++ templates useful, though.

  // Jorgen Grahn <jgrahn@       Ph'nglui mglw'nafh Cthulhu
\X/      >   R'lyeh wgah'nagl fhtagn!

More information about the Python-list mailing list