Python Programming, news on the Voidspace Python Projects and all things techie.
I Got Slashdotted (Nearly!)
I noticed a spike in traffic to my website last night, and all referred from an entry at the googlegroups mirror of comp.lang.python.
Very weird - must be an error in my site stats software, I supposed.
Until I sussed it, the news that Guido Van Rossum has joined google has been slashdotted.
A proportion of the visitors are clicking thru to my site. Ah well, it's an ill wind...
It's very good news that Guido is joining google (congratulations to him - and to them on their good taste). It sounds like they will be freeing him up for about fifty percent of his time to work on Python. Fantastic.
It's the day before the day before Christmas, work is quiet, and I have time to make frivolous blog entries like this - hurrah - oh and happy Christmas to you all.
Movable Python Mailing List
I've just created a mailing list for Movable Python.
On topic are bug reports, feature requests, questions and suggestions regarding Movable Python.
Movable Python is a distribution of Python (for windows) that need not be installed. It comes with the SPE IDE, and various other tools, to make it a fully portable 'Build, Test, and Run environment. It easily fits on a USB memory card - Python a Stick.
I've set the group up in anticipation of the new version, which will be released in the early part of the new year.
Movable Python is useful for :
- Machines where you don't have admin rights (can't install programs)
- Where you need a portable 'Build, Test, and Run' Python environment (will nicely fit on a usb memory stick)
- Having several versions of python on the same machine for forward/backward compatibility testing
- Easily deploying python scripts without having to install python
- Try before you buy - test python without having to install it, including new versions
- 'Python Runtime Environment'. '.py' files can be associated with movpy
It could also be used to create generic executables for windows . You can create an executable that will work with any standard Python features, but keeps your main code as a Python script. That way you can make changes to your code, without having to re-compile with py2exe each time.
Anyone interested in this aspect of Movable Python will have to contact me - as it will require a special build.
|||Movable Python uses py2exe under the hood.|
Archive and Contents
I've updated the contents page. It now has a brief description of all the projects, and is up to date again.
I'm still building this by hand. Until rest2web can build it for me, it will tend to lag behind reality (whatever that may be).
I've also moved several completed or unmaintained items into a new page called the Archive, the graceful resting place for finished projects.
Projects and code now in the archive include :
- caseless - Case insensitive dictionary, list, and sort
- splitter - Split and recombine large files
- includer - intelligent include directive for Python
- PyName - Wordlist of words with 'py' in them
- dateutils - a simple set of functions for dealing with dates
- HTTP Test - a test CGI for examining HTTP headers, cookies, and authentication
- Random Link - A couple of simple CGIs for sending people to random places on the web
- Victory Days - A tool for my church for administering Victory Days
Python(like) Documentation in reST
There has been some discussion about developing the Python documentation in reST. Unfortunately it seems that reST, as a plain-text format, is unlikely to ever develop the complexity needed to replace LayTeX as the python documentation format .
That aside, it would still be nice to have a tool that built docs that look like the Python documentation from reST sources. The Python documentation is very attractive, and the 'Next', 'Previous, and 'Up' blue arrows make them very usable as well.
It occurs to me that this means it should be easy enough to provide each page with links to it's 'Next', 'Previous, and 'Up' pages within it's namespace.
If I can extract the page contents from docutils (I have some example code to do this), then it should be possible to autobuild full contents pages for a directory as well. Unfortunately, splitting larger documents down into several pages is probably beyond me (until docutils provides a way of doing it anyway).
This means that it would be possible to create Python-like documentation using rest2web. The only limitation is that site are built top down, so directories wouldn't have easy access to the contents of directories below them. Building large contents pages that include subdirectories wouldn't be possible (yet).
|||It also allows you to keep content as HTML, so it can be used as a templating system (that will autobuild index pages) for any website - without requiring you to use reST.|
|||Specifically, a syntax to mark functions and arguments and build indexes from this data, is required.|
SPE the Python Editor
SPE is a fantastic editor. After a long time debating about which editor to use I settled on SPE as my one true editor. It has lots of nice features - and Stani the developer is very quick to respond to feature requests and problems. Nice one.
Recently added features include workspaces for projects and a new system for running code from within SPE.
Python Search Engine
The Python Search Engine now searches from over fifteen hundred domains and has served over nineteen hundred queries.
I need to add Next and Previous buttons to allow deeper searches, and then I'll release the code.
Killing the Guestbook Spammers
I was getting several spam messages a day, so it should be very easy to tell if it works or not. (My changes worked first time as well - so far so good anyway).
Assuming it works, I'll put all the previous entries back on and do a new release. I'm also working on a version 2 which has a full web interface for editing the templates/entries. It uses logintools for the user account/authentication stuff. This will enable guestbook owners to mark entries as spam and report false positives back to akismet. It may be a while before it's done, but it will get there eventually.
Pythonutils and ConfigObj
Pythonutils 0.2.5 is now available.
Pythonutils is a pure-Python package containing several modules that help with common programming tasks in Python.
This new release updates to :
- ConfigObj 4.1.0
- odict 0.2.1
- validate 0.2.1
- pathutils 0.2.4
- cgiutils 0.3.5
(Also included are standout, listquote and urlpath - which haven't been updated since the last release).
In the meantime - enjoy.
Ordered Dictionary 0.2.1
There is a new version of odict - the ordered dictionary.
What Is It ?
This module provides two classes OrderedDict, and SequenceOrderedDict. The ordered dictionary is a dictionary-like object (actually a subclass of the normal dictionary data type) that keeps keys in insertion order.
This means it has all the normal dictionary methods. Methods that would normally return values in an arbitrary order are now ordered.
You can specify and alter the order, through the setkeys method.
Because an ordered dictionary is something like a sequence, it also has several sequence methods. The SequenceOrderedDict allows you to act on the keys, values, and items directly - as if they were sequences. This is convenient if you want to treated your object more like a sequence than a dictionary.
What Has Changed ?
This is a major change since the 0.1.0 series. OrderedDict now has several sequence methods - including allowing slicing, slice assignment, and slice deletion.
OrderedDict is compatible with Python 2.2. Slicing isn't - mainly because you can't index a sequence with a slice object in Python 2.2.
It also has a subclass called SequenceOrderedDict that has custom, callable sequence-like objects, for items, keys, and values. You can call them like the methods they replace, or act on them directly as sequences to change the contents of your dictionary.
You can now test for equality and inequality with objects (except for dictionaries for which it is undefined). This allows you to do tests like :OrderedDict() == False
Added the strict keyword, which raises a ValueError if you do slice assignment with keys that are already in the dictionary.
Assignment to keys in SequenceOrderedDict is now only for re-ordering the keys.
Fixed bug where slice assignment to keys could lose information. (and optimised by slicing ranges to get the indexes we are assigning to instead of indexing each key).
You change keys, items, and values through new methods setkeys, setitems, and setvalues methods.
Minor changes, thanks to Christoph Zwerschke for suggestions.
Added __deepcopy__ method (previously deepcopy failed).
Changed use of slice to types.SliceType for Python 2.2.
Fixed bugs in __getattr__ and popitem
Optimisation in OrderedDict.__init__ when creating an instance from an OrderedDict.
Implemented new __repr__.
Added index to OrderedDict.popitem
Implemented SequenceOrderedDict, which has keys, items, values as custom, callable, sequence objects.
By Michael Foord - from suggestions on comp.lang.python
Hidden the sequence attribute
Implemented slicing (including deleting a slice and assigning to a slice)
Implemented sequence methods sort, reverse, insert, index.
ConfigObj 4.1.0 and Validate 0.2.1
ConfigObj 4.1.0 and Validate 0.2.1 are now available.
ConfigObj and validate have both had moderately big updates.
What are they ?
ConfigObj is a simple but powerful config file reader and writer: an ini file round tripper. Its main feature is that it is very easy to use, with a straightforward programmer's interface and a simple syntax for config files.
It supports nested sections, preserves the order of keys and sections, list values, multiple line values, etc.
validate integrates with ConfigObj (but can also be used standalone) to check that values meet a certain specification. This can be used to validate a config file, and convert values to the expected type.
What Has Changed?
Added a merge method. This allows easy merging together of several config files (e.g. merging user values on top of a default one).
A new flatten_errors function to turn the results dictionary from validate into a flat list of errors.
Added merge, a recursive update.
Added preserve_errors to validate and the flatten_errors example function.
Thanks to Matthew Brett for suggestions and helping me iron out bugs.
Fixed bug where a config file is all comment, the comment will now be initial_comment rather than final_comment.
Validation no longer done on the 'DEFAULT' section (only in the root level). This allows interpolation in configspecs.
Also use the new list syntax in validate 0.2.1. (For configspecs).
A new list syntax for checks.
Fixed bug so we can handle keyword argument values with commas.
We now use a list constructor for passing list values to keyword arguments (including default) :default=list("val", "val", "val")
This work is licensed under a Creative Commons Attribution-Share Alike 2.0 License.