Python Programming, news on the Voidspace Python Projects and all things techie.

Python 2.6

emoticon:python Python 2.5 isn't even out of the door yet and Python 2.6 features are already being discussed. Smile

PEP 359 discusses a new language feature planned [1] for Python 2.6.

This would add a new piece of language syntax, the make statement. It allows you to create custom (named) namespaces without all the machinery overhead of the class statement.

I often use classes to create namespaces for related attributes, so I might use this [2].

There is a danger in adding new syntax to the language. Python 2.4 and 2.5 have both done this, with decorators, generator expressions, the with statement and conditional expressions [3]. Python 2.6 already proposes to do this by changing the import semantics in the form of relative imports.

This creates two difficulties.

  1. When using new syntax features it is basically impossible to write code that will still work on previous versions. Even if you check the Python version at runtime, to ensure that the code is only executed on an interpreter that can handle it, the parser will still choke.
  2. It raises the bar for people trying to learn the language. When looking at code they have to be able to recognise more language constructs to have a chance of understanding what is going on.

Python doesn't suffer from being defined by a standards body, choking all possible improvement, but it seems to be growing rapidly. I believe that Python is in good hands, and some of the recent additions add great power in the right hands. Having said that, the reason I fell in love with Python was the emphasis it placed on readability and clarity. I hope those taking Python into new and uncharted territory remember axiom number three from the Zen of Python :

Simple is better than complex.
[1]Or at least being discussed...
[2]Various other use cases are discussed in the PEP, including the suggestion that it could replace the class statement entirely. Surprised
[3]Plus the new unified try/except/finally.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-04-13 17:03:10 | |

Categories: ,


Snowcrash

emoticon:beaker I've got a few days off whilst I'm in between jobs. We move on Friday, so the next couple of days will be very hectic. In the meantime I'm doing a hasty update to one of my programs.

To accompany the headscratching and mind-numbing work, (and having finished Angela's Ashes) I'm now listening to Snow Crash. This is written by Neal Stephenson, one of the heroes of Cyberpunk.

Its theology is distinctly dubious [1], but that aside it is very interesting [2]. I'm particularly drawn to the Metaverse. This is a virtual world created by computer hackers.

It is similar to the cyberspace envisioned by William Gibson, but more of the details are fleshed out. From my point of view, the most exciting thing about it, is the ability to create new things. Stephenson doesn't describe the mechanics of virtual matter and energy, but programmers are able to create new and working objects like motorcycles.

I've searched the web [3] to look for the hackers who are creating the Metaverse. Despite the rise of the MMORPG, where people can interact in virtual worlds, I can find nothing similar. All the ones I've seen have a fixed and rigid infrastructure. Objects must be built into to the fabric of the world, so you're unable to create new ones from the inside. Sad

I'll have to wait, or build the Metaverse myself. Wink

Note

I was explaining to a friend recently how humans had managed to create such complex things as computers.

Computers are (currently) based on silicon wafers, with circuits containing hundreds of thousands of transistors - switches.

Despite the complexity of modern devices, they are built from combinations of circuits comprised of very simple components. At their heart, microprocessors are still descendants of mechanical devices like The Difference Engine of Charles Babbage.

The basic component of the human is the cell. A cell is a phenomenally complex device, a miniature chemical factory that operates on the quantum interaction of its inner workings. Each of us have hundreds of millions of these cells.

So despite packing untold numbers of transistors onto silicon wafers, humans are still a long way off achieving anything remotely approaching the complexity of the human body (and mind). Smile

[1]The philosophical (or Spiritual whichever floats your boat) suppositions are predicated on the fact that the resurrection is a myth.
[2]The real world it describes is a little silly for my tastes, the virtual world on the other hand...
[3]A bit...

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-04-12 16:14:36 | |

Categories: ,


rest2web Markup

emoticon:boxing_gloves In working on rest2web I've realised that it would be very easy to support other markups.

The ones that spring to mind are :

Would anyone find that useful ?

I've also discovered that the current system of uservalues is broken in lots of cases [2]. To fix this I think I need to add a new syntax for including uservalues. I will probably go with :

<* uservalue *>

This allows uservalues to contain ReST and still be turned into HTML.

[1]Although it seems that wiki markup is a nebulous concept, with every Wiki having its own variant. Anyone know of a good standalone Wiki-format-to-html module for Python ? Bonus points for not suggesting I extract the rendering engine from MoinMoin but providing a link to the right module instead. Razz
[2]I anticipated this, but I didn't realise how serious it was. Now that I'm making uservalues more general I have to fix it.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-04-10 09:25:18 | |

Categories: ,


rest2web Progress

emoticon:car There has been some tangible progress on rest2web at last.

There is an updated version in the SVN Repository.

rest2web now supports three levels of verbosity via command line options :

  • -v Verbose (the default)
  • -a Actions & Warnings Only
  • -w Warnings Only

There is currently a bug in the handling of the file keyword when use in conjunction with the index-file keyword.

Update

The file bug is now fixed in SVN. Smile

After this there are several new features to be added before the next release.

Other rest2web news; the Leipzig Python User Group are having a meeting on April 11th. Mike Müller is giving a talk on rest2web. Shame it's a bit far for me to go, but it should be interesting. Wink

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-04-09 15:10:14 | |


New CGI Repository

emoticon:pda Once again, thanks to the folk at Python-hosting.com, there is another Subversion repository for some of the Voidspace Python Projects.

This one is for my CGI Projects, and can be found at :

http://svn.cgi.python-hosting.com/

This contains the following projects (each in their own folder on the trunk [1]) :

  • downman

    File download Manager.

  • guestbook

    The Voidspace Python Guestbook.

  • logintools

    An authentication and user account framework for CGI applications.

  • Other

    Containing :

    • akismet.py

      Interface to the Akismet anti-spam web service. It includes an example CGI.

    • approx

      A Python CGI proxy with a couple of related programs.

    • contact

      A simple script to provide a contact/feedback form on a website. Undocumented, but easy to use.

    • HTTP

      • Upload Scripts

        A CGI script/module for receiving uploads from a web form.

        Also a module for uploading files by HTTP, using urllib2.

      • HTTP Test

        An example script showing cookie handling, basic authentication, fetching URLs and understanding HTTP headers and the CGI environment variables.

    • Nanagram

      An online anagram server script.

    • protectedpage

      A simple example that shows how to use the logintools framework. This examples protects static html files behind a login.

    • randlink

      A couple of scripts that can redirect users to a randomly chosen URL.

    • skimpy

      A CGI search engine that uses the Yahoo Web Services. Undocumented, but the code is well commented.

    • webcounter

      A simple script that counts visitors to a webpage.

Of particular interest may be the following :

  • Guestbook

    The version in SVN has several improvements over the latest released version. It has a couple of bugfixes, uses the akismet.py interface, and has additional anti-spam measures.

  • skimpy and contact

    Both of these are previously unreleased. I was going to wait until I had time to write documentation and make a few improvements, but in the meantime...

A lot of this code is quite old, Nanagram-CGI was one of the first programs I wrote. Despite this, my CGI page is one of the most popular on my site. It got around five thousand visits in March. Smile

The reason for getting the repository is that I will be writing an application soon(-ish) that will integrate logintools and downman. Although that won't be Open Source, it ought to lead to considerable improvements in both.

I also need to do a new release of the guestbook before giving it the complete refactor it needs (which will add an administrative interface, amongst other things). I'm not sure when this will happen though.

[1]There are also copies of released versions, where appropriate, in tags.

Like this post? Digg it or Del.icio.us it.

Posted by Fuzzyman on 2006-04-08 22:03:50 | |

Categories: , ,


Hosted by Webfaction

Counter...