Archive for December, 2007

Two tips for using ScribeFire

December 4, 2007

I’m using the Firefox Add-On ScribeFire to collect information before posting to my blog. I works perfectly for that task. It is available at no cost from https://addons.mozilla.org/en-US/firefox/addon/1730 (Homepage: http://www.scribefire.com/)

But there are two tips for using it:

  1. [Update: The following behavior is fixed in recent versions.] Do not forget to save all the things you entered in the editor. There is not auto save function. I you switch between different posts or notes you will lose any unsaved information from the editor.
  2. Using the wordpress feature you should use the “Source Editing” Tab for the Editor and not the “Rich (normal) Editing” Tab. The latter one will add <br> to every line of your source code. These will be visible if you publish the post to the blog.

Otherwise it works really good!

Technorati Tags: , ,

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 http://svn.python.org/projects/python/trunk python
$ svn co http://svn.python.org/projects/doctools/trunk 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 sphinx-build.py -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 (http://docs.python.org/lib/typesseq-mutable.html). The trick was provided at http://ada.rg16.asn-wien.ac.at/~python/ 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]
'a'
>>> 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: