I don’t really consider myself a Python developer, although I have dabbled. As with many of the less mainstream languages there are keen developers and thinkers trying to clear away the confusion and push the limits of what is possible.
Snakes on the Web
The article is an enthusiastic call to action for “Pythonistas”, but also a really useful summary of big problems and issues applicable to any language, framework or development approach. Read it, even if just for the excellent (and scary) summary of all the things a modern web application developer needs to be aware of.
I’ll admit that I don’t have a lot of experience with Python, but one of the things which always gets me in a tangle is project structure, modules, packages, importing and how they all play together. So far I have not found much by way of resources to help newbie Python folks get to grips with “best practice” in this area.
This post looks like it might be helpful, though.
jcalderone: Filesystem structure of a Python project
It’s a long-running argument. Are modern, dynamic, languages such as Ruby and Python really much more concise than more mainstream languages such as Java? What constitutes “big” in each case? Stephan tries to flush out some hard facts, and gets a lot of comments.
Comparing Java and Python – is Java 10x more verbose than Python (LOC)? A modest empiric approach at Stephans Blog
So the question is: are dynamic-typed languages (ruby, python, smalltalk, etc.) easier or harder to maintain than static-typed languages (Java, C#, etc.)? It seems there are arguments both ways.
On the one hand, dynamic languages tend to be a bit more concise, and reducing code size is a great way to simplify maintenance. On the other hand static languages typically support better and more intelligent tooling, which is also a great way to simplify maintenance.
Ola Bini has some thoughts, but has so far been unable to come up with any hard data one way or another. is there any?
The Maintenance myth | Ola Bini: Programming Language Synchronicity
I have been working with Python a fair amount recently, and really miss a lot of the tool features I use when working with Java. In particular, lacking the ability to automatically apply common refactorings and auto-complete obvious code really “cramps my style”. In most cases I have a pretty clear idea of what I want to do, and how I want to get there, but I find that the process of using Python is just more laborious.
I guess that puts me squarely in Ted Leung’s group of “experienced developers” rather than the “early adopters” who are happy to use more generic tools in order to gain the benefits of a new language and its abilities.
IDE’s and Dynamic Languages at Ted Leung on the Air
I had great hopes for this when I saw the title. I normally use TDD (Test Driven Development) exclusively, but have been finding it difficult to get into the rhythm of TDD when developing in Python for Google App Engine. I’m just not familiar enough with the Python unit-test ecosystem. So a general purpose Mock Object framework looked as if it would be a useful tool for the toolbox.
Google Open Source Blog: Check Out Mox, Our Mock Object Framework for Python
Unfortunately, it uses my least favourite approach to Mock Objects: switch the Mock into “record” mode, manually perform a sequence of actions, then switch the mock to “replay” mode and run the real code to compare it against the recorded expectations.
In the Java world this is the approach taken by EasyMock. In a strongly-typed, pre-compiled language such as Java, this is just about excusable in order to gain method call validation in the IDE or compiler. But in a more flexible language I really can’t see the point.
For me, the overwhelming disadvantage of the record-replay approach is that it implies that there is only one complete correct sequence of collaboration calls, and that anything else is an error. In real systems this is simply not true. Some calls might be optional (such as a “getter” which may be cached”); some calls may be unimportant to a particular test; some calls may be happily repeated many times (such as a “hasMore” or equivalent status call); and most importantly, some calls may occur in any order.
Although typical record-reply frameworks try to address some of these issues, every such attempt makes the operation of the framework more clumsy and less obvious. It’s very hard to address the fundamental problem.
In my opinion, a much better approach to mock objects is for the Mock object to simply record all the calls made during the running of the test, and then provide a flexible set of accessors and assertions to apply to the result. That way, whoever writes the test case can also easily write specific assertions, such as asserting that the count of calls to “hasNext” is always one more than the count of calls to “next” without requiring special support in the framework.
Does anyone know of a more sensible Mock framework for Python?
This is a really useful article for what I am doing right now. A selection of Google AppEngine hints and tips from someone who has done a few apps already. I particularly like the reminder about providing static favicon and robots.txt files – something I have bumped into in plenty of other web development situations but had kind of forgot in the excitement of playing with AppEngine.
Google App Engine optimizations
I’m not really a NetBeans user (I tried using it for a while when it was mandatory for a recent course) so I don’t care much which languages it supports. However, I do seem to be slipping over from Ruby to Python as my alternative language of choice at the moment, so a note that Sun values Python enough to bring in support in NetBeans is another good sign.
InfoQ: Sun Gets Serious About Python
A page pointing at some App Engine code examples:
google-app-engine-samples – Google Code
or alternatively, just svn checkout the trunk from
I’ve been looking at Google App Engine recently, and thought I’d have a go at developing something using Eclipse (my main IDE) with the Python development plugin PyDev rather than a motley collection of text editors and scripts.Â Here’s how I got on so far.
I already have Eclipse Europa, so I connected to the PyDev update site I told PyDev where my Python interpreter is located and accepted the default pythonpath entries, then created a new PyDev project and pasted in the example code from the Google App Engine tutorial.
All was going well up to this point, but then I hit a problem. PyDev was showing errors in the code indicating that it could not find the App Engine modules and classes to import.
I looked around the internet and found the following links purporting to help:
Adding in the pythonpath settings from the first one didn’t seem to work. I tried a variety of combinations including creating a new appengine project with the appropriate source folders and referenced it in my new project. Still no luck.
So I created a new project following the steps in the second link, and there were no import problems, even though by default it contains a very simple web application using the App Engine. So I copied and pasted the code from the offending module into the new project and everything seems fine now. I have set up the dev server as a run target in Eclipse and it runs sweetly.
I can only assume that it was the order in which I did things, somehow. Perhaps adding pythonpath entries after code is already present is not picked up correctly by PyDev. Dunno, but I hope this helps someone.