Python Programming, news on the Voidspace Python Projects and all things techie.
First Impressions of the Macbook Pro and Mac OS X
I promised you my first impressions of using a Mac laptop. It was a bit long for a blog entry, so I've written it up.
I have recently started using an Apple Macbook Pro laptop on my daily commute and for developing. Having only ever used Windows it was quite a switch. This article records my first impressions of the Apple laptop and the Mac OS X operating system.
Whilst looking for ways to improve my 'Resolver in the Browser' I discovered EditArea.
The features include Python syntax highlighting and it works very well.
It also provides a 'goto line' line dialog, full screen editing, a find and replace dialog, undo and replace and so on. It is very easy to configure and program with (not a drop-in replacement for textarea but a reasonably sane API) and makes an excellent addition to my application.
Ruby is Hard
Ola Bini, one of the core developers of JRuby, has posted a blog entry about some of the intricacies of Ruby:
I actually have nothing against Ruby, in fact it is doing a very good job of popularising dynamic languages. Plus the fact that Andrzej (a new blog entry is overdue Andrzej!) likes it means that it can't be all bad.
If it wasn't for the fact that I'm itching for a good excuse to explore some of the Python web frameworks I might even be tempted to learn it.
Ola's entry worries me though. His example code is:
class Foo attr_accessor :bar def initialize(value) bar = value end end
In this code, the meaning of bar = value is dependent both on the context (of being an attribute accessor) and on the casing of the variable name. Apparently this can bite even experienced Ruby-ers. The fix (kinda ironically) is to use self to make bar an instance rather than a local variable.
Now every language has its quirks (and Python is no exception), but it seems like a clear example of both why an explicit self is a good idea and making casing semantically significant is a bad idea.
To be honest though, I'm slightly swayed by the argument that programmers should be allowed to attach methods to the built-in types if they want to. I still think that doing it is a bad idea, but making it impossible does seem to go against the Python philosophy of giving programmers as much rope as they want (to hang themselves with or otherwise). I also like the fact that with Ruby (allegedly ) you can catch the use of undefined variables with method_missing. With Python's equivalent (__getattr__) you can only catch access to missing methods and attributes. This feature makes for more expressive DSLs.
In Python (from 2.4 I believe) you can achieve the same effect by exec'ing code in the context of a custom object that will dynamically provide variables when asked. This requires keeping code as strings or compiled code objects though, so does not lend itself to creating frameworks with.
Another nice feature is being able to use exclamation and question marks in method names. This makes for some nicely expressive method names, and naming is everything...
|||Andrzej made me promise not to quote him on this...|
Resolver in the Browser with Silverlight (a Preview)
As part of the Silverlight talks I'll be giving at PyCon and Mix I'm writing a version of Resolver that runs in the browser.
I had to use a few tricks to get the grid to do what I wanted. When you enter edit mode in a cell I dynamically swap out the value to be edited. It needs to be the formula rather than the displayed value. If you leave edit mode without making a change, you don't get the 'afteredit' event which I need to swap the displayed value back in, so I had to work around this. Plus reloading the results after an edit loses the selection (the data must be reloaded because changing a single cell could change the displayed value in any cell that depends on the one you have edited). I'm sure there are better ways of achieving some of the things I've done, but sometime I'll post the code for you to vilify.
Despite being small, it is basically a full spreadsheet engine. One nice touch is the output pane. I divert standard output so that print statements in the code go to the output pane. Very useful for debugging!
Entering values or formulae in cells generates Python code (in the correct order) which is executed to generate the results. You can enter arbitrary code in the user code pane which is executed before the generated code. You can use .NET objects or define functions here which can be used in formulae, you can also set cells from code.
Tasks left are to make it look prettier (!) and to add a front end that accesses a server side web application for loading and saving spreadsheets. This will use some of Silverlight's AJAX capabilities. Christian showed me how to get a simple Pylons application started. It was astonishingly easy and will be ideal for my needs.
The only remaining issue (of about ten minutes ago anyway) is that it interacts badly with one of my Firefox extensions and crashes Firefox. I have a VM image where it runs fine with Firefox, but not on my main machine.
Python in London Banking
I got contacted by a headhunter asking if I was interested in a job as a 'front office developer' for a London hedge fund. The position commands a lot more than I am currently on (in excess of £100K with bonus), but there are various reasons why I don't want the job (plus reasons why they might not want me). Basically it boils down to the fact that I am really enjoying my job and learning a lot, and I figure that a situation like that is worth a lot. Additionally the job description notes that it involves working with traders who are "demanding users". There are more appropriate adjectives than demanding...
Anyway, there is a lot that is interesting about this job.
- Their production systems are in C#, Python and Lisp
- The required experience is in any of the top three object oriented languages - Java, C# or C++. Python experience is not a requirement
I regularly hear about London banks, and hedge funds, that use Python. Usually my information is from job adverts and 'third parties', you rarely hear directly from those in the banking industry who use Python.
I figure that banking is another 'dark market' for Python, where it is used a great deal but rarely as active members of the community. (EWT being a notable exception of course.)
The reasons that Python is suited to this high-pressure industry probably include the following:
- Rapid development
- Experienced programmers can learn Python very quickly
- Simple cross-platform deployment
- Debugging interpreted languages tends to be easier (and require simpler tools)
- Hot fixes can be applies in place, just by modifying a source file if necessary
- A mature language, with good performance, that interfaces to C libraries and other languages
- A wide variety of quality libraries available
In an environment where a software failure can start costing a lot of money very quickly, some of these points will be extremely important.
IronPython at Mix UK
The speaker and talk information has gone up for the Mix UK conference:
Mix UK is a Microsoft conference for developers and designers. This year there is a lot on Silverlight.
I'm speaking in the afternoon on day 2. Apparently my talk is entitled "Python et al: Using Dynamic Languages in .Net and Silverlight". That's not exactly what I agreed with them, but close enough.
Interesting New gadgets
Several new gadgets have launched recently:
A 'storage robot' that handles redundant backup with hot swap and addition of drives for you. Looks easier to configure and use than RAID.
It costs $499 in the US and has just become available in the UK for £350. The usual premium for buying in the UK.
At the moment I have more than enough storage, but Drobo would be a safer solution.
A small Linux based home computer that costs as little as $99 plus a subscription fee. It uses online storage (S3 according to Ian Bicking).
It sounds like an excellent hacking device, but without the subscription fee it costs $249 which is not such a bargain for small devices. Still tempting though.
Another small hackable computer gadget. This is effectively a soft toy with a screen and a computer behind it. Widgets are apparently programmable with Python and flash! Very tempting.
Ok, so this isn't a gadget at all. The Multiverse is a software platform for creating MMOG.
It is still in beta (despite the 1.0 release) and the client crashed a few times for me. Plus I couldn't find anyone else in the few example worlds at the time I tried. The worlds are pretty slick though. Apparently parts of the worlds are scriptable in Python.
It's interesting because online worlds are interesting, but this is a platform for creating online worlds. Now I'd love to script an online world in Python.
On the subject of gadgets, my phone contract is due soon. I can either wait for the iPhone, or wait for the next version of the Open Moko. Hmmm...
Resolver at PyCon UK
- Test Driven Development, Jonathan Hartley
- The New Age of the Amateur: End-user Computing without Tears, Giles Thomas
- IronPython in your Browser with Silverlight, Michael Foord
All of the Resolver staff will be there, and I'm really looking forward to the event. Apparently 125 people have registered already! This is great news for the Python scene in the UK.
Talks I'm particularly interested in include:
- The Bazaar Version Control Project, Michael Hudson
- Using and Developing with Python Eggs, Stephen Pascoe
- The PyPy Project, Michael Hudson
- Building Systems with Kamaelia and Kamaelia Core Internals, Michael Sparks
- An Introduction to Twisted, Richard Wall
- Stackless Introduction, Christian Tismer
And of course the keynote by the effervescent Simon Willison. There are lots more that look interesting though.
This work is licensed under a Creative Commons Attribution-Share Alike 2.0 License.