Posts Tagged ‘Python’

Building Boost.Python 1.42 for QNX 6.4.1

June 8, 2010

Building the Boost C++ libraries ( for QNX is pretty straight forward. The build can be executed as described in the Boost documentation. I have performed the build of Boost 1.42 using QNX 6.4.1 installed in a virtual machine.

But there was a little tweak required to build the Boost.Python library. The problem is that python is located in /usr/qnx641/host/qnx6/x86/usr/bin/python but the required Python include files like Python.h are located in /usr/qnx641/target/qnx6/usr/include/python2.5. This setup is confusing the automatic detection of the include files used in the build process.

This can be fixed by providing the right include path, e.g by adding the following line to the file <boost_src_dir>/project-config.jam:

using python : 2.5 : /usr/qnx641/host/qnx6/x86/usr/bin/python : /usr/qnx641/target/qnx6/usr/include/python2.5 ;

Script fails with “No such file or directory”

July 9, 2008

While running a script it fails immediately with “No such file or directory“. Even a print or echo command in the second line of the script is ignored. The used program to process the script does exist and is running, too. In this case checking the line endings may help:

file nameofthescript

will report:

ISO-8859 English text, with CRLF line terminators

but expected is:

ISO-8859 English text

The problem are the CR/LF line endings. These are typically used from MS Windows applications. Correct the line endings using any editor. For MS Windows try the Notepad++ open source editor. It has a build-in menu item to fix the line endings: Format -> Convert to Unix.

Generating the Python docs on a Ubuntu GNU/Linux box

December 4, 2007

The first thing is to checkout the Python and doctools directories from the subversion repositories:

$ svn co python
$ svn co doctools

To install the required tools, as suggested from the doctools/README, I added the following packages:

# apt-get install python-pygments python-docutils

These are the steps really generating the documentation:

$ cd doctools
$ mkdir build-html
$ python -b html ../python/Doc build-html

Open the files generated in build-html, e.g. build-html/index.html, using file->open using your favorite web browser.

Everything works pretty straight forward as described in the doctools/README file.

Technorati Tags: , , , ,

Modify a read only tuple

December 4, 2007

Using tuples is very handy because of their flexibility and speed. But there is a drawback. Assigning a single item to a tuple does not work and results in a

 TypeError: object doesn't support item assignment

Appending to the tuple does not work, too. The reason is that tuples are immutable (read only) data structures ( The trick was provided at how2think/english/chap09.htm: replace the old read-only tuple with the new one where two tuples are concatenated:

>>> tuple = ('a', 'b', 'c', 'd', 'e')
>>> tuple[0]
>>> tuple[0] = 'A'
TypeError: 'tuple' object does not support item assignment
>>> tuple.append('A')
AttributeError: 'tuple' object has no attribute 'append'
>>> tuple = ('A',) + tuple[1:]
>>> tuple
('A', 'b', 'c', 'd', 'e')

Technorati Tags:

Example for creating a compressed file using Python

November 30, 2007

This example shows that the same methods can be used to writing a normal text file and a compressed file. Corresponding reading functions are provided, too.