4 comments Tuesday, May 22, 2007

In the last days, i've been committed to learn C++ so I can port performance critical methods in my Python apps to it. I found a great site - www.cplusplus.com with a nice tutorial worth a look.

I started reading thru a lot of documentation on how to create Python C modules but all those PyObjects and all made a mess in my head.

Looking in the Python-Ogre (Python bindings for the wonderful Ogre3D engine), I found that they use a new code generator for boost-python called Py++.

I heard a lot about boost and its qualities so I figured out that this was the best option and with Py++ to create the wrapper files it became easier.

The problem was not how to create the wrapper files and generate the modules but and install that bunch of packages and modules on windows was a pain.

What you will need:

- Compiler (I'm using VS2005 Express since its free)
- Platform SDK R2 (Windows headers)
- Python (Of course...)
- 2 eggs ... oops... forget this one
- Boost installer for Windows Easier to install, better than compile yourself.
- GCC-XML
- Pygccxml

The resumed installation procedure is:

- Install the compiler and the platform SDK
- Configure your compiler to use the 'libs', 'includes' and 'bins' from the SDK
- Configure the vcvars32.bat file to add the SDK paths to it so the Compile console finds the headers.
- Run the boost installer, it will download the needed packages from a mirror. I installed the base packages and the Python lib.
- Unpack and run 'python setup.py install' on GCC-XML. In my case, it have not compiled with VC2005 so I unpacked myself and followed the instructions here. Then I compiled using the generated solution file.
- Install the pygccxml package 'python setup.py build install'
- Install the py++ package 'python setup.py build install'

Thats it for now... in my next post I will post some examples and procedures for generating the C++ modules.

0 comments Friday, May 11, 2007

Reading a post from a Planet PythonBrasil blog today, our friend Rodrigo Cacilhas has proposed some approaches on the Oddwords puzzle where the objective is to invert the odd words in a phrase.

The post can be seen here: http://kodumaro.blogspot.com/2007/05/oddwording.html

I created a small solution based on list comprehension and the and-or trick. It´s like this:

text= "abc def ghi"

print " ".join([(x%2 == 0 and y or y[::-1]) for x,y in enumerate(text.split())])

It shows how powerful list comprehensions can be.

0 comments

First post, new blog.... well, this will be the place where i will write about programming, tech and discoveries I find around the internet.

Keep your eyes here for great content.