December 28, 2008

PyCon 2009 Presentations

I've just been thinking about planning for PyCon, and I have a lot to do. The tutorial schedule is a little bare right now, but I am hoping it will be fleshed out soon. There are over 30 tutorials, two of which I am involved in.

Firstly I have to write Python 401: Some Advanced Topics (not my own choice of title), which is supposed to discuss iteration, generators, descriptors and metaclasses. These are all features of Python that could stand some more explanation, but I'd like to put a twist on the material and have the audience suggest potential applications that we can discuss as a part of the tutorial.

There's a second tutorial, Python for Teachers that I'll be presenting jointly with Kirby Urner. The idea behind this one is to try and enthuse those involved with formal education about Python's potential for teaching mathematics of various kinds. Kirby has a lot of experience doing that, and I am supposed to provide irreverent questioning and keep Kirby headed in the right direction. He's the education side, I represent the geeks, if you like. I'm really looking forward to it, but I owe Kirby email about those plans.

Then I have to give an invited talk which I believe will be a plenary session, though that hasn't been confirmed yet. My working title for this is Leading the Python Tribe, in which I want to investigate the shared sense of direction in the Python community, in so far as it currently exists, and offer some thoughts about the roles of the Python Software Foundation.

I am also hoping to run an Open Space session along the same lines as last year's Teach Me Twisted, but this time looking at web testing - an area I would really like to learn more about. I think I have Grig Gheorghiu interested in helping out, but he's a busy guy and hasn't yet committed. If anyone can rope in the knowledgeable web testers we need it's Grig.

To top this all off there'll be the PSF members meeting to chair, sundry sessions in the bar, meals with friends old and new, and all the other wonderful things that happen at PyCon with absolutely no formal scheduling. So I expect to be busy, but I also expect to enjoy myself hugely. See you in Chicago?

December 17, 2008

Sun Developer Network Podcast

It's taken quite a long time to get through the production cycle, but here's a podcast of Ted Leung and me discussing Python 3.0 migration. Something to listen to on the commute?

December 13, 2008

We're TravelNow.com, and We Fail

Don't you just hate it when an advertised email address fails? Particularly so when you've sent the email to notify a company about a problem with their web site? It's surprising how some quite large companies fail to pay proper attention to the basics, and I came across a perfect example today.

I've just booked a trip with Jet Blue, and wanted to add a car rental reservation to the booking. Let's ignore for the moment the tedium of having to enter the same details twice due to a lack of integration between Jet Blue and TravelNow, as the price of lower-cost flying. Alas, when I click the "printable version" link after completing the rental reservation I see a pop-up window saying "Unrecoverable error: if this persists please email webmaster@travelnow.com". Being a good web citizen and having a certain fellow feeling for anyone who struggles to keep the Intarweb working I dash off an email with the URL and my reservation details, only to receive the following missive:

Oh well, these things happen in the best-regulated domains, I guess. An email to postmaster should sort it out. I mean after all, RFC2821 explicitly says
SMTP systems are expected to make every reasonable effort to accept mail directed to Postmaster from any other system on the Internet. In extreme cases --such as to contain a denial of service attack or other breach of security-- an SMTP server may block mail directed to Postmaster. However, such arrangements SHOULD be narrowly tailored so as to avoid blocking messages which are not part of such attacks.

so that's bound to work, right? Wrong:

So I guess the lesson here is "we don't care if there's anything wrong with our web site, and we haven't bothered testing our customer feedback channels". If this company has stockholders, they should be asking questions.

Yes, I have verified my own domain's webmaster and postmaster addresses. I thought it would be a good idea before I made this post. Can you say the same?

Edit: A colleague pointed out that I had amused her by including a typo in the email address, which I have now fixed. So I am not as good at checking the basics as I'd like to be myself ...

December 6, 2008

A Pythonista Lending Group?

I've finally taken the plunge and become a lender with Kiva. It got me wondering whether there might be some potential for a lenders' group in the Python world. I know from personal experience that it contains many people with philanthropic and charitable instincts. If you'd like to join in, let me know.

December 4, 2008

Python 3.0 Is Out

Even though I am on vacation this is worth a quick note. After long efforts by many developers Python 3.0 was released today!

I posted a short article a while ago about 3.0 (in)compatibility, but the differences between 2.6 and 3.0 aren't so great. It's perfectly possible to write 3.0 code that will run on 2.6 too, as most of the language hasn't changed at all.

The preferred strategy for writing code that runs on both versions is to write in 2.6 and then apply the 2to3 converter and verify that it produces a correct 3.0 program. There's no guarantee that it will, so you may need to paraphrase the 2.6 code a few times before you get a transatable program.

Once all the third-party modules you and extensions you rely on are 3.0-ready, and you no longer have clients requiring 2.6 version of your software, you can simply drop the 2.6 compatibility requirement and start to make use of the few 3.0-only constructs that have been introduced.

December 2, 2008

Religion is not Python

About six months ago I made a post called Python is not a Religion, discussing some aspects Python advocacy in response to some comments by Doug Napoleone. About two weeks ago I see a new comment (by Jonathan) appear against that piece:
I noticed that your Blogger profile says "Catholic tastes" for your favorite music. Are you a Catholic, and would you be interested in joining the recently formed Association of Catholic Computer Programmers?
Firstly, I should like to point out that I am not a member of any church. I have no interest at all in worshipping anybody else's imaginary friend, though I try (with varying degrees of success) not to make too much fun of other people's delusional belief systems. I have my own to maintain. In this case I am going to make an exception. Without my really knowing why, this particular comment got right up my nose. I suppose, now I think about it, it's the shallowness of understanding that led the person to post the comment. Google has a lot to answer for.

Secondly, the word "catholic" in my profile is specifically used in the sense of "free from provincial prejudices or attachments", but apparently some Catholics don't appreciate that the name of their church has a broader (and far less exclusionary) meaning, dating back to the days when you were Catholic or you were on the rack, buddy. The Catholic church is so named because it was originally the "general or universal" Christian sect. Of course Henry the Eighth laid waste to that when he started the Church of England, and as far as I can see the Christian faith has more branches than the average oak tree. Whatever.

The Association of Catholic Computer Programmers (Catholics interested in software engineering best practices) appears to be a little schizoid. Are they a social network, a religious institution, or a movement? Some of the discussions are interesting, with comments like "I think we should start a project to benefit a charity of our choosing and put our collective talents as Catholic SEs to good use", which makes me wonder what skills Catholic software engineers have that I don't.

The same guy who started ACCP has started "a pro-life network", though apparently it have only four nodes so far. There's a pretty badge people can use "to identify themselves as being pro-life". Well, of course I am pro-life. Without life I'd be nowhere, and you wouldn't be reading this drivel now. In fact I find it difficult to understand how any living being can be anti-life, with the exception of the dysfunctional. But of course there's a hidden semantic trap there: the opposite of pro-life isn't really anti-life at all, it's "murderer".

The most revelaing thing of all to me is that neither the ACCP nor the above-mentioned network are prepared to do what enabled the commenter to make his or her comment in the first place. They require sign-up to make any sort of input to their site, while my blog allows anonymous comments from anyone (though as a spam reduction measure they aren't immediately posted). So the Catholic Programmers aren't at all catholic in their approach to discussion.

I know a lot of good Christians, but I don't want to join that club. Sorry. I suppose Jonathan can only hope there's no such thing as bad publicity.

November 13, 2008

LodgeNet Censoring python.org?

So, here I am at this hotel, using their network to browse the web as one does, and I suddenly see this web graphic notifying me that my network access has been blocked for ten minutes because "[the] server has detected questionable traffic originating from this computer".

At first I was concerned that perhaps I had unwittingly picked up some virus or other malware, so I made a call to the "support" team to see if they could tell me what was wrong with the traffic. Of course, I might as well not have bothered, since they couldn't tell me anything about why this might have happened without me being "naughty" in some undefined way. After ten minutes the service came back on again, only to be lost once more as soon as I retried a web access. So it seemed to me there was something extremely significant about the URL I was trying to access, which was actually the documentation for the PIL ImageDraw module.

A further support call elicited the information that the help desk couldn't do a bloody thing about anything, had no idea why the content was being blocked, and weren't interested in helping to change whatever bizarre piece of policy was responsible. Several times they mentioned that "the server will cut you off if you are downloading, there's nothing we can do about that", leaving me somewhat perplexed about what they thought the Internet was for, but of course I assured them that I had only been "browsing," which is apparently different.

It would have remained a curiosity had I not then received the same response when I tried to visit the Python programming language home page. Now suddenly the position is different, as I am the chairman and an officer of an organization whose web site is being subjected to censorship. So I have sent the customer service department at LodgeNet the following snotty letter. We'll see whether I get any response, but I am not holding my breath.
Sirs:

As a resident at the Town and Country Resort Hotel on San Diego, California, I have been a consumer of your company's service. Several times I have had my service blocked, seeing the attached graphic.

Calls to your customer service department elicited no useful information as to how I could stop this unwarranted blocking of my service, and the staff involved, while sympathetic, were completely unable to help (and indeed appeared to know nothing at all about the policy responsible for this). The only suggestion they could make was that "downloading" would cause the service to be blocked: hardly helpful, since I was merely browsing the web and handling email.

My fourth call to your support desk was put on hold and then unilaterally terminated. This is completely unacceptable.

Experimentation demonstrated that your service blocker appeared to come into play when the certain URLs (among others: my patience was limited) were accessed. I would emphasize that my use of bandwidth was *not* excessive; the previous evening I had transferred a couple of PowerPoint and PDF files, but no malicious content of any kind was involved.

http://www.pythonware.com/library/pil/handbook/imagedraw.htm (documentation for a graphics package)

http://python.org/ (the home page for the Python programming language).

This last site is of particular concern to me as I am the Chairman and a Director of the Python Software Foundation, the organization responsible for the site.

I would like to know why you are censoring our web site, and what you propose to do to make sure that its content is available to all who wish to access it.

Sincerely
Steve Holden
Chairman, Python Software Foundation

Don't Use Python 3.0? Really?

It's difficult to say "don't use Python 3.0" without being rude to the developers, as the code seems to be of very high quality. Now that Python 3.0 is almost here (release candidate 2 is a week old as I write) we should encourage people to use it, but only under well-defined circumstances. Here is some text I put together for inclusion in the release notes, to give people guidance about when and why it is and isn't appropriate to use 3.0. I would welcome further ideas to refine this text.
Readers should note that this release has significant backwards incompatibilities with the 2.X series, both at the language level and also in the C APIs available to extension module authors. These have been introduced by design, with the goal of improving the language in the long term, but this situation has implications for production use.

Furthermore it is likely that there will be a considerable delay before some authors of Python packages and extension modules start to provide 3.0-compatible releases. There are significant hurdles to be overcome in migrating extension modules from Python 2 to Python 3.

For these reasons you are NOT recommended to rely on Python 3.0 as your main production Python implementation until you know that all supporting code is available in compatible forms. While every care has been taken in the production of the Python 3.0 release, and the release team feels that the system is of a quality comparable with the recently-released Python 2.6, the latter system is currently the recommended version for production use.
I hope that clarifies things, but I would welcome further ideas to refine this text and make it more helpful. One of the primary reasons for using 3.0 is to get a migration strategy ready. But 3.0 is undoubtedly not for everyone, at least not just yet.

November 12, 2008

Phrase From Nearest Book

Well, here's a turn-up. I spotted this meme on Grig Georghiu's blog.
  • Grab the nearest book.
  • Open it to page 56.
  • Find the fifth sentence.
  • Post the text of the sentence in your journal along with these instructions.
  • Don’t dig for your favorite book, the cool book, or the intellectual one: pick the CLOSEST.
As luck would have it I am on a trip to San Diego and the only book I have with me is Rapture for the Geeks by Richard Dooling. [Disclaimer: Richard was kind enough to send me this book in return for a programming favor I did him some time ago]. By the most amazing coincidence, when I examine the bookmark I placed to make a telephone call I see I am currently reading page 56! Here's the fifth sentence:
If he is gay, man needs man; otherwise, man needs woman.
This doesn't actually represent the compelling nature of Dooling's prose particularly well. For that I like the next two sentences rather better:
Not photos or Web clips or blog entries or text messages or e-mails or even video clips taken of or sent by woman. Man needs woman in the flesh, in meatspace, where he-meat meets she-meat to beget meatlets.
Anyway, it will be interesting to see what others come up with.

November 11, 2008

United.com Broken

So I have this trip coming up to San Diego, and I fly tomorrow. I get this friendly little Web-2.0 e-mail from United. It comes from an address in a subdomain of p0.com, telling me that United are using Yesmail, and it includes a link for me to follow to "view my complete itinerary". They even have it link to a server in the p0.com domain so my browser doesn't think this is a phishing attack. The only problem comes when I click on the link, and repeatedly see 
Connection Interrupted
The connection to the server was reset while the page was loading.
The network link was interrupted while negotiating a connection. Please try again.
"Not to worry", I think to myself, "I'm a United frequent flyer (God help me), so I can just log in to my Mileage Plus account and check my itinerary there". Of course this wouldn't have been much of a post if that had worked, but good old United didn't let me down. Every attempt to log in gives me
Redirect Loop
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete.
Attempts to retry just bring up the same message again. Wonderful. Let's hope the people who run the web site have nothing to do with keeping the 'planes flying.

[PS: Fortunately this appeared to be a transient condition. The site now responds normally.]

November 10, 2008

Final "Introduction to Python" of 2008

As the year draws to a close Holden Web is pleased to remind readers that its final public "Introduction to Python" class of this year will be held from December 9-11 at our education center close to Washington, DC.

There are several hotels conveniently located within walking distance, and we provide breakfast snacks and lunch each day.

Purchase places on-line by credit card or using PayPal.

Thanks to all students who have already attended this class. We look forward to meeting you again as our range of course offerings increases.

November 9, 2008

For Would-Be Python Users

If you are new to Python, or know someone else who is, you (or they) could do a lot worse that visit Richard Dooling's Seven Minutes to Hello World web page. It explains about the easiest way to get Python up and running on your Windows XP computer.

I am pretty sure it will run for Vista too, the only reservation I have being the need to run the installer as an administrator if you want to install Python for all users. Since most Vista systems are single-user machines anyway, this isn't likely to be a big issue.

November 7, 2008

World Plone Day? Communicate, Dammit!

So just now, somewhat after midday Eastern Time, I discover that today is World Plone Day.

Forgive me for saying so, but as Python Software Foundation chairman I should have expected to hear about this event a little in advance. I would even have welcomed the opportunity to lend PSF resources towards publicizing it, seeing as how Plone is one of Python's showcase applications. Alas apparently nobody thought to try and use the PSF as a channel. So I hope World Plone Day goes well this year, and that it doesn't pass everybody else by as it did me.

For the record, the PSF runs its own blog, whose articles are well-syndicated on the web, and we are also usually happy to put Python-related events as front-page news on the python.org web site.

If you are running some newsworthy event, mail the webmasters (if you aren't savvy enough to work out the correct email address, webmaster at python dot org should get you there) to avail yourselves of the opportunity! However can we achieve world domination if we continually hide Python's light under a bushel?

October 30, 2008

A Joke, or an Accident?

I can't decide whether Greg Wilson posted this as a joke. In case he didn't, and whatever error induced this behavior is fixed by the time you click on the link, I attach a current screenshot. Click on the image to look at the title and see what amused me.

Either way I think it's funny. No, it doesn't take a lot to amuse me. I guess I'm just a geek at heart.

October 29, 2008

Stani Wins Coin Design Competition

If you subscribe to the Planet Python feed you will already know that Stani (this is to the best of my knowledge the only name he advertises), the author of the well-known Stani's Python Editor, just won a competition to design a new Dutch five-Euro coin.

Congratulations, Stani, and not just for an exceptionally creative use of open source software (including Python, naturally), but also for a fine demonstration of its ideals. What a pity you can't release the coin under a copyleft agreement!

It seems to me this is just another area where the demonstrable abilities of open source are only just beginning to make an impression. You ain't seen nothing yet!

October 26, 2008

Norton Antivirus 2009 on Vista is a Liabilty

Today, for the second time in less than two weeks, the first attempt to collect mail after a reboot cause the appearance of a rather unpleasant notification dialog indicating that my Antivirus software has stopped working:

The first time this issue occurred I spent almost four hours online with the Symantec support technicians, having my software removed and re-installed several times without any resolution of the issue. At that point I had to go out, and when I returned the issue was somehow gone. I assumed that some component had been automatically updated, and continued on my merry way.

Today, we went through the same remove/re-install rigmarole with no more success. After the technician (who was controlling my computer remotely) went quiet for three or four minutes, then he closed the browser windows and disconnected the support session. Thanks very much.

The really annoying thing is that this is a known issue that Symantec claim will "be fixed in the next support upgrade", but there is no information about when this upgrade will happen, and neither does there appear to be a workaround I can apply until the fix appears, short of falling back to Norton Antivirus 2008. So I suppose that's what I'll have to do.

I'm guessing there are a lot of other people experiencing the same issue, because I started out as eighteenth in line for support. I am now next, and looking forward to going back to the prior release. But that was installed by a Symantec technician in response to a long-forgotten problem with the 2008 product, so I may not be out of the woods even then. If Symantec think I'm renewing at the end of my current subscription period they have another think coming. I have already spent almost a full day without email twice because of this issue, and I've had enough.

For some reason a number of posts were stuck in the blog as drafts. This one is from October last year.

October 21, 2008

It's Here!

I may be an old fart, but I know when a 'phone is going to be cool. To think I was actually the guy who registered "gPhone.com" (for a client). It would be nice to see Steve McCarthy and Guy Jazynka get something for the name. They might even buy me a pint!

At least I get a chance to play with Chrome. So, who knows where the Python interpreter is?

Shame I am feeling so ropey, I'd have loved to spend the evening playing on the Intarweb. Maybe tomorrow I'll blog from the 'phone.

October 15, 2008

Django Tip: Non-editable Fields

Yesterday I explained how to subclass a DateTimeField, adding a pre_save() method to make it suitable for use as a row creation or modification timestamp. If you do this, however, you will observe that unless you add an editable=False argument to the field instantiation call they will appear as editable fields in any ModelForms containing them. It would clearly be more desirable to have these fields non-editable by default, which can easily be arranged by extending their __init__() method and changing the default value of the editable argument.

The code below also renames the fields more suitably. You can use a similar trick to create other non-editable field types, and also to change other instantiation defaults.

class ModificationDateTimeField(models.DateTimeField):
def __init__(self, editable=False, *args, **kw):
models.DateTimeField.__init__(self, editable=editable, *args, **kw)
def pre_save(self, instance, add):
val = datetime.datetime.now()
setattr(instance, self.attname, val)
return val

class CreationDateTimeField(ModificationDateTimeField):
def __init__(self, editable=False, *args, **kw):
models.DateTimeField.__init__(self, editable=editable, *args, **kw)
def pre_save(self, instance, add):
if not add:
return getattr(instance, self.attname)
return ModificationDateTimeField.pre_save(self, instance, add)

October 13, 2008

Django Tip: Field.pre_save()

Here's a little thing that can help you to improve the flexibility of your models.

Rather than trying to extend or override Model.save(), if the special action you require only affects one field then define a subclass of the required Field type and define a pre_save() method on the subclass. This will override the default method, which simply returns the attribute value.

I spotted this by following up a discussion of the planned removal of the DateField's auto_now and auto_now_add attributes, which you can assert to set a modification or creation date respectively on rows. Some developers suggested putting the functionality in a decorator that could be used on the model's save() method, but Jacob Kaplan-Moss preferred a trivial subclass:

class AutoDateTimeField(models.DateTimeField):
def pre_save(self, model_instance, add):
return datetime.datetime.now()

Unfortunately this is just a little bit too trivial, since pre_save() is required to set the attribute value - every time for auto_now and on first save for auto_now_add. Fortunately the extra code required is pretty small. pre_save() receives three arguments: the first is the field instance, the second is the model instance and the third is a flag which is True only when the save() call is adding a new row to the associated table.

class AutoNowDateTimeField(models.DateTimeField):
def pre_save(self, instance, add):
val = datetime.datetime.now()
setattr(instance, self.attname, val)
return val

class AutoNowAddDateTimeField(AutoNowDateTimeField):
def pre_save(self, instance, add):
if not add:
return getattr(instance, self.attname)
return AutoNowDateTimeField.pre_save(self, instance, add)

Technically it would be cleaner to use super() to access the superclass methods from AutoNowAddDateTimeField, but as a proof of concept this works fine.

As it happens the auto_now and auto_now_add attributes of DateTimeField were not removed before the release of Django 1.0, so we are likely to be stuck with them until 2.0. But the same technique is useful for any field that needs to receive an automatic value when a model instance is saved.

October 2, 2008

Python 2.6 Released

Thanks to release manager Barry Warsaw and a cast of thousands! Get it from the usual place.