December 31, 2009

Open Source Documentation, Again

I had a whole blog entry written, but sadly the new and "improved" Blogger application appears to have eaten it. Personally I don't think they have improved the application, as ^Z after setting something to a block quote now appears to delete the complete entry contents, the preview is way less friendly in the new popup format, and the editor icons don't seem as intuitive as they used to. Overall I think I'd rather go back to the previous version, but there doesn't seem to be any way to do that.

Anyway, to cut a long story boring, I just wanted to point out that when I went to update my Cygwin installation (hoping that Python 2.6 and/or 3.1 would now be available, which sadly they aren't - where's Jason Tischler when you need him?) I got a parse error on the setup configuration file. No biggie, the setup program even pointed out that I probably needed to download a new copy, and when I did so the updated copy told me to read the Cygwin documentation to find out what I needed to know to update from 1.5 to 1.71 (I presume 1.6 was omitted for some reason).

Sadly when I went to the Cygwin home page the only relevant information I see is "PLEASE read the new User's Guide before upgrading your Cygwin installation to 1.7. You're avoiding trouble."

This is OK, but when I follow the link to the users' guide I get a list of three different possible formats plus links to two different quick start guides and another link to Setting Up Cygwin. It's only by clicking one of the users' guide links that I finally discover the link, in the table of contents, to What's new and what changed in Cygwin 1.7. Guess what? None of the information in there relates to upgrading from an earlier version, so I am left with the only hint being the note at the start of the home page that says
Please note that the update from Cygwin 1.5.x to Cygwin 1.7.x might require some manual changes afterwards. Most notably the mount point storage has been moved out of the registry into files. User mount points are NOT copied into the new user-specific /etc/fstab.d/$USER file. Rather, every user has to call the /bin/copy-user-registry-fstab shell script once after the update.

Now I don't want you to think that Cygwin's documentation is lousy. In fact the situation might seem less problematical if the documentation were worse, but generally Cygwin is up there with Python and Django in terms of the quality of its documentation. All of which only makes it seem more jarring that there is no specific advice to use migrators, even though the project home page seems to imply a) that there is, and b) that it's important to read it.

Anyway, I am going to finish this post now, before Blogger decides it's time to delete all my typing again. Happy New Year!

EDIT: Interestingly the original entry came through on Feedburner, but I decided to leave the revised entry as it was, modulo this edit. As is so often the case, a re-work improved the quality of the work.

December 24, 2009

New Podcast: A Little Bit of Python

For some time Andrew Kuchling has been agitating to get a Python-based podcast going. He's finally made it by teaming up with Jesse Noller, Brett Cannon, Michael Foord and me. We have now recorded three episodes, and I believe the first two are already available via RSS feeds:

Choose from the MP3 version or the AAC Version (better for iTunes). The first two episodes are a little chaotic. It will take us a while to work out how to collaborate most effectively, but I am sure it will improve with time.

I'm interested in any and all opinions of the podcasts, and of course if you can let us know what topics you'd like to hear about we'll try and accommodate you. Please send e-mail to all at bitofpython dot com. We'll do our best to listen and respond.

Finally, since there's just half an hour to go before Christmas Day, a very Happy Christmas to all my readers.

December 23, 2009

PyCon Asia Pacific Call for Papers

If you would like to visit Singapore next year, please consider submitting a paper to PyCon Asia Pacific, which runs from June 9-11 next year. The call for papers is open until February 1, but why not get that proposal in before Christmas?

December 21, 2009

PyCon Financial Assistance Closing Date Looms

If you want to go to PyCon but won't be able to make it because of financial constraints, please remember that the PSF does make some limited financial assistance available to assist in such cases. Yes, it's a band-aid, but one that can help increase the conference's diversity and ensure that interesting voices that wouldn't otherwise be heard have the chance to speak up.

The assistance program closes tomorrow, Tuesday December 22, so if you want to apply then please do so quickly.

This year, thanks to Google's generosity as a sponsor, we have additional funds with which to try and increase the number of women attending. Obviously we would prefer to use the funds to sponsor women who wouldn't otherwise be able to go (otherwise we won't increase attendance, we'll just subsidize women who would have attended anyway).

Happily the PyCon world appears to be rife with good common sense, so I don't anticipate problems. See you at PyCon!

December 19, 2009

Please Publicize PyCon

If you have a blog, now would be a good time to use it to start encouraging people to attend PyCon. In Atlanta, from February 19-21, with two days for tutorials before and up to four days of sprinting afterwards, it's likely to be the best and biggest PyCon to date.

I would be especially grateful if you would make sure that word gets out to people who might otherwise not think about coming to PyCon. The conference thrives on new blood - typically at least fifty percent of delegates will be attending their first PyCon. There are badges you can use to give your posts a graphical flavor, too.

I'm using the badge above because I am speaking early on the first morning about Building the Python Community. There are others you can use if you are attending, or giving a tutorial. So please, do everything you can to make this the best PyCon ever (which won't be easy, given the event's history). And have a very Happy Christmas!

December 17, 2009

Skribit Schmibit?

I just noticed that Skribit log the number of followers for each writing suggestion on the blog, and some of the suggestions that have been made actually have people following them. Presumably this means that people would like to read such posts, so in the New Year I am going to try and pen at least one article a week on a Skribit topic.

This leads me to the question: how do I tell Skribit that a particular piece satisfies one of their suggestions, and should therefore be notified to the list of followers. Or is Skribit just making this information up as they go along? If you can't help me I'm going to have to read the FAQ ...

December 15, 2009

Slap on the Wrist for Microsoft China

[EDIT:As Michael Foord points out in the comments, the actions described below were taken by a company with which Microsoft had contracted. Microsoft appear to have acted in good faith once the duplicity was discovered].

I'm not terribly happy with the "Evil Empire" theory of Microsoft. There's little doubt that when the company was younger it was an aggressive competitor up to and occasionally beyond the limits of the law, and there was a culture of "what's good for Microsoft is good for the world". The company has been known in the past to take information obtained from smaller partner companies and use it to build competing products and services, to the partner's disadvantage.

But I know quite a few people who work in Microsoft, and none of them are the kind of people who I would expect to indulge in any kind of ethically questionable behavior. I have assumed, perhaps naively, that as the company grew its culture would be molded more by the requirements of the legal jurisdictions it operated in, and less by the cowboy ethic of earlier years. Silly me.

The latest and most egregious example of Microsoft rip-off behavior comes from China, where the Microsoft subsidiary in November published a "Chinese copy" of Plurk Asia's micro-blogging service. Following the link will make it obvious this isn't just a cosmetic copy - the similarities appear to extend deep into the code base.

Given Microsoft's holier-than-thou approach to piracy issues, particularly with regard to the Chinese and other Asian markets, it makes one wonder who took the decision to go ahead with this project, and why heads haven't already rolled - or maybe they have? I hope (but alas sincerely doubt) that it costs Microsoft a lot of money to put this right, since it appears that money is the only thing that Microsoft understands.

December 13, 2009

Abstract Programming? Structured Music?

People sometimes claim that programming is an art (me, I am happier to regard it as a craft, notwithstanding the fact that one of computer science's greats is writing a book called The Art of Computer Programming). If the parallel were clearer then presumably we'd be able to do abstract programming (people do abstract visual art, right)? What the hell would that represent?

All of which is a rather feeble introduction to a few of my brother's abstract images. David has way more talent in the arts than I do (he's also a very talented musician). Since I find both his art and his music appealing, and since he is currently trying to make it more accessible, I wanted to find out whether his work generally appeals to geeks, or is it just my starry-eyed fraternity that makes me like his work?

Since this blog is mostly read by geek (when it's read at all ...) it seemed like a good place to ask the question. So, what's the answer? Comments, please.

December 11, 2009

How Do You Update Your Content?

Since I moved to Django I've been struggling with the question of how to keep the site's body content up to date. I started out just editing the body pages' HTML, which was stored in the database (crude, but it did allow an earlier transition to Django).

I've since experimented with various mechanisms, including two WYSIWYG editors in the Django admin (not sufficiently expressive) and a full content management system (too cumbersome and tricky to install, though it may become the favored solution eventually). For now I've settled on a scheme that allows me to keep the body page text in the database as either ReStructured Text or raw HTML, but I am sure this is far from the best answer.

So how do you keep your web's textual content up to date without going crazy?

December 10, 2009

Talk at PyCon, Become a TV Star?

Well, maybe not a star, but who knows? You will certainly get to meet a lot of interesting people with a common interest in Guido van Rossum's invention. And sessions are televised. Last year I posted two months after PyCon to point out that there had been 180,000 views of PyCon-related videos on blip.tv.

Of course it's too late now to be a speaker at PyCon 2010 if you haven't already been accepted - those decisions were made a while ago (with great difficulty, as there were so many excellent submissions this year).

It would be interesting to hear from some of the quarter of a million people who've viewed the PyCon videos just to see what you thought was good and bad about them. They certainly make information about Python much more readily available.

The people who speak at PyCon (and the many other Python conferences throughout the world) are stars anyway, in my opinion, and deserve our support. They are giving freely of the experience they have developed, and they deserve our thanks and recognition. PyCon speakers don't get free registration or much else in the way of reward, so when you are at the conference (or if you come across one of them elsewhere) please let them know how much you appreciate their work.

December 8, 2009

Reaching Out to the .NET World

If you know people, particularly in New York city, who work with Microsoft's .Net environment I'd be grateful if you could make them aware of Michael Foord's .NET: IronPython from the Ground Up class, running on January 21.

My main contacts with the .NET world are currently limited to the SharePoint environment (yes, you can use the SharePoint APIs from IronPython), and I suspect (but do not know) that the .NET world isn't quite as heavily imbued with the open source ethos as the Linux/UNIX world is.

I think we still need to get the word out. Despite all the noise about the DLR introduction (including excellent publicity in MSDN magazine), plus the availability of IronPython and IronRuby, dynamic languages don't yet appear to have the traction in the .NET space that they do in the Unix world.

Or am I talking through my hat? I've written before that I think the Windows environment is a great platform for supporting open source applications -- if you think about it, it's the logical way to put open source on the majority of desktops.

The event should also be of interest to the existing Python user base who want to be free from some of the CPython implementation's current restrictions. Here are some of the reasons why you might consider IronPython:

* Using Python libraries from .NET
* Using .NET libraries from Python
* Writing multi-threaded Python code without a GIL
* Embedding IronPython in .NET applications for user scripting
* Exploring new assemblies and classes with the interactive interpreter
* System administration and scripting
* Developing for Silverlight (Python in the browser)

I've been a Resolver user for over a year now, and I've been impressed with IronPython's stability and usability. It would be nice to see more .NET users at PyCon

Note: the seminar linked above is a commercial activity of Holden Web LLC

December 4, 2009

Why Soldiers Deserve Proper Respect

People who know me well (and there aren't that many of them) have asked me why, when I am so at odds with the policies that led to the Iraqi and Afghanistan wars, I insist on differentiating between the cause in which the service is enlisted and the service itself.

This article says far better than I, who have never served in any country's armed forces (and was grateful, growing up, to escape the conscription that killed men only two or three years older than me), why I feel respect is due to the men and women who stand up to serve their country in the military.

I remember being amazed in 1987 to meet some Viet Nam veterans in San Diego and hear at first hand the difficulties they had getting the benefits to which they were entitled. I disagreed with the Viet Nam war too, violently, but was shocked to find that a country could turn its back on the youth it had conscripted to fight its battles in its "backyard" (yeah, right).

The conscription now is largely economic. I have a brother-in-law who learned his trade in the army because it was the only place that would teach him a trade, but it crafted him in other ways too. I remember the amazement of his family when he came home after basic training and made his own bed unasked. I remember too, later, the nervous tic his eyes acquired (and retained) from too many attacks on the troop carriers he drove in Belfast. He joined the army because it offered him the best career opportunities. There are a lot of people today who are joining up for the same reasons. Economic opportunity does not abound for the youth of today's America, and so many of the least fortunate will choose to serve their country. Would that the congressman and senators would protect them as they protect their own sons and daughters.

So I hope, when those who have served return, that this adopted country of mine will find more than empty words to honor the service they have performed. "Thank you for your service" means less than nothing if it isn't accompanied by a place to live, a secure income, a decent standard of living and an honest appreciation of the time spent in harm's way.

Much as I regret President Obama's decision to send yet more troops to Afghanistan, he was at least honest about his intentions during his campaign. I hope that this further investment of America's young men and women will lead to a real improvement in the most corrupt country in the world (or is it the second most corrupt, I forget). Those who agree with his decisions must accept that they bring with them a cost: that of ensuring that the survivors, and the families of the fallen, are not left standing in the cold once this economic winter, manufactured by the bankers in their snug financial parkas, is over.

Hell, if bankers and politicians had to fight wars in person this world would be a far more peaceful place. It's too easy to condemn those in uniform to die by proxy for some policy with purely economic motives. At least, for the moment, this country appears to have a commander in chief who properly weighs the lives he risks. If I felt I had the right I would salute those who venture forth, knowing not whether they will ever return.

December 3, 2009

Google Thinks I'm Naughty

I've been doing quite a lot of web stuff lately, and this has involved doing link checking on my site. Since it now has AdWords in it, this means my (totally unsophisticated) web crawler has been following the advertisers' links. Oops.

This afternoon I get an email from WellKnownSearchEngine saying:
It has come to our attention that invalid clicks have been generated on your Google ads, posing a financial risk to our AdWords advertisers. Please note that any activity that may artificially inflate an advertiser's costs or a publisher's earnings is strictly prohibited by our program policies.
You can imagine the rest. Dire Warnings, Serious Threats, and so on, coupled with a refusal to offer specifics. So I just thought I'd ask: what tools do you use use for link-checking, and how do you avoid this issue?

December 2, 2009

Way Back When?

So what's with the Wayback Machine, then? Or, to be more specific, why did it appear to stop archiving holdenweb.com in October, 2007? It's not like I think my content is so valuable that it would be a loss to the Internet, but it would be nice to understand why the archiving suddenly stopped.

I'm still waiting to hear back from the Internet Archive, but I have a nasty suspicion that the answer is going to be that Cool URIs don't get indexed. I hope not. More information when it becomes available.

November 29, 2009

Comments or Not? Public or Private? Relevant or Irrelevant?

Recently I heard that some people aren't happy about changes made to PyPi, the Python Package Index. As far as I am aware there is only one person who has been working on that application recently, and that's Martin von Loewis. Martin, last year's winner of the Frank Willison Award, is a Director of the PSF and someone who works tirelessly at various aspects of Python -- many of them not particularly rewarding. As with many open source activities it is (I assume) a labor of love.

Recently Martin updated the Package Index to allow users to leave comments, and it appears that this innovation has been contentious. As a result of the rumblings Martin created a poll to determine whether the feature should continue in its present form or be modified in various ways. Here are the results as at the time of this writing:

Allow ratings and comments on all packages (status quo)



223
Allow package owners to disallow comments (ratings unmodified)



137
Allow comments, but only send them to package owners (ratings unmodified)



33
Disallow comments (ratings unmodified)



24
Disallow ratings and comments (status three months ago)



88

This is all very well, but unfortunately it appears that PyPi is now boxed into a corner. Even if the most popular option is implemented (retaining the current situation, where the newly-added rating and comment feature is allowed on all packages) this guarantees that a majority of those voting will have their favored option rejected. I suppose this demonstrates that you can give people too many choices.

My own discomfort with PyPi goes rather deeper. While I think that it's great that we have a central repository to support setuptools (even though release 0.6 is now three years into its release cycle and onto its eleventh release candidate) and now distribute, I would like to see it become much more usable than it currently is. It would be easy to see this as an attack on the implementers and maintainers (which it is not intended to be: the maintainers of all the software I have mentioned have done valuable work that I could not). Honestly, it isn't.

In reality I think it would be good if they had more help. Particularly the kind of help that let them package the facilities this excellent tool PyPi provides, in a much more obvious way. Even if this means complaining about the way things currently are.

Almost as a side note, I ended up following a twisty little maze of (web) passages all alike which finally led me to the Python issue tracker. Since it showed an apparently remembered login name and password I assumed all I had to do was click the Login button and all would be well, but apparently not. So I did what any user would do, and followed the Lost your login? link.

Alas, neither my email address nor my user name was recognized on that page, so I decided the only thing I could do was to register an account (even though I know I have submitted bugs in the past). So I went through the registration process only to be presented with the following unhelpful message:


OK, so what the heck is all that about? How am I now supposed to proceed if by chance I have burning information about a bug in the Python system? I have said before, and I will say again, that as an interface between Python's users and its developers the issue tracker sucks. I am sure it is very useful for the developers, but as an input collection mechanism it seems to be only slightly less valuable than a customer service desk staffed only by a notice reading "go away" (I am exaggerating for dramatic effect here).

[Edit: this was apparently a bug, which has now been fixed at least for the Python bug tracker.]

I suspect that what is needed here is the e-mail equivalent of a help desk, where people with no knowledge of the infrastructure can exchange messages with a team of real human beings who know what the score is and can make any necessary inputs to the issue tracking system on their behalf. Call them user proxies, if you like. I am aware that in the high-tech world of open source this may be seen as a heresy, but people still have their uses, dammit, and they clamor to be useful even as the capitalist world declares them redundant by the hundreds of thousands.

Now I know before I post it that some people are not going to like this article: they will either say that I shouldn't be complaining if I'm not prepared to fix what I'm complaining about, or that I should not be making a noise about something that third parties will use as evidence that the Python world is in some sort of disarray. Frankly I don't buy either of those arguments.

The Python world has recently gone through a long-drawn-out and extremely energetic discussion about increasing the diversity of the community. As an existing community we are fighting an uphill battle, because it's even more difficult to change the constituency of existing communities than it is to recruit a diverse mix to new ones. Just the same this has had some very positive results, not least the publication of a diversity statement that I think the Python Software Foundation has every right to be proud of -- it might seem like a simple piece of text, but it was a hard-won development that even cost us the resignation of a member.

Yet despite all that work, we apparently haven't yet got to the stage where the Python community includes people who can look at a less-than-optimal interface and say out loud "we need to do something about this". I don't know if this is because we are too close to PyPi to be able to acknowledge its faults, or because people fear hostile responses if they make negative comments about the infrastructure, or (perhaps most likely) because they don't want to offend those who have invested their time and effort into producing something, at least, which is more than most of us do. I do know that it frustrates the hell out of me.

So let me put a public stake in the ground here. I have visited a number of local Python user groups in the past year (the first PSF chairman to do so, as far as I can tell). Almost everyone I have spoken to along the above lines has been enthusiastic about making things better, and willing to volunteer to help make the necessary improvements. So now I need to hear from the broader Python community about what's "wrong" (less pejoratively: what we should change to make things better). This means you.

The Python Software Foundation is currently looking quite critically at next year's activities and the budget to support those activities. If we are going to make a real difference to the perception of Python and to its adoption as a serious IT solution to a broad range of problems then we need broad involvement from the whole community, not just the PSF membership. I am investigating a number of ways in which the PSF could encourage a broader involvement, and it would be helpful at this point if there were general evidence of a desire by non-members to get more involved in Python: not just its development, but its community.

If this piece isn't enough to get a decent discussion going then I suppose I should just resign as PSF chairman and look elsewhere for a community that gives a damn. I honestly don't think that will be what I need to do. I'm really hoping you guys don't let me down here.

November 20, 2009

Starting 2010 With a Bang

Holden Web's first one-day workshop was, thanks to Jacob Kaplan Moss, a sell-out success. As a result, and partially due to some excellent feedback from the New York City Python Meetup group, we will be running the same workshop in New York on January 22, again with Jacob presenting. We are also offering a one-day IronPython workshop presented by Michael Foord on January 21.

Since the three-day Introduction to Python classes have been well-received in Virginia we are also offering that class in New York on January 18-20.

To try and make things easier for those attending and smooth out our administration we are using Eventbrite for the first time. I would really like to know how easy people find it to get information about our classes and to enroll for them. Anyone wanting specific information not mentioned in the course outlines is, of course, welcome to contact us for further details.

If you would like to take one of these classes simply follow the links above (or click here for a list of all our current offerings, then just go to the ones you are interested in) and click the Order Now button which should be clearly visible. Once you have entered the details click the Review Your Order button, and you have fifteen minutes to check that you have entered the correct information before you click the Pay Now button. It really couldn't be much easier, I hope.

We are also very interested to know what other event you would like us to run. This is the front end of a new venture for Holden Web, and your opinions and requirements (places you'd like to attend presentations as well as other topics) will help us to move in the right direction. So feel free to contact us with your suggestions, or make them in comments below. Thanks in advance for the feedback.

November 17, 2009

Two Thousand Posts Behind

While recording material for the first three episodes of a new Python podcast (you'll have to wait*) I realized that I've been less in contact with the doings of the Python community than usual over the last six months, due to project and teaching work.

When I am in "less busy" mode and have some spare time I often follow the comp.lang.python newsgroup, offering advice and opinion when the occasion allows. I also find the time to track the Planet Python newsfeed, which is full of interesting (and often detailed) information about what various Python personalities have been up to. When I get busy, as I have been this year, those information sources tend to take a background role.

I just started on the task of "catching up" with Planet Python, and have had to recognize that there is no way I am going to. There have been over two thousand posts since the start of June this year, and I just don't have the time to run through it all -- particularly not if I want to follow up all the interesting stuff I see. In the first minute of examination I saw details of an IronPython application that allows you to examine .NET binary assemblies and instantiate the various classes you come across, interacting with them through an interactive console.

This was interesting because it's been one of the reasons many Java shops keep Jython in their toolkit. Java is also a compiled language not an interactive one, and so it's difficult to learn about the tools without going through an intensive "write/run/debug" cycle that makes it difficult to condense your experience into learned material. With Jython you just use the interactive Python interpreter, creating instances as you like, calling their methods and examining their attributes. "Plays well with others" has always been one of Python's strengths.

Anyway, suffice it to say that there's been some amazing stuff going on in the Python ecosphere recently. I am really looking forward to next year's PyCon (February, in Atlanta). There were so many great proposals that even with an expansion from four tracks to five there wasn't room to accommodate all the stuff that could have gone in. So expect some pretty amazing Open Space sessions too!

* Provisionally entitled "A Little Bit of Python"

October 31, 2009

Google Mail Weirdness

I'd be delighted if somebody could explain what the hell's going on here. I switched mail for the holdenweb.com domain to run through Google's Gmail for Domains service. Things had been going quite nicely, and the spam levels had reduced amazingly without me having to apply any external filtering (which makes me wonder just exactly why Google Groups is so clogged up with the output of asshole spammers, but that's another post).

Recently I have started to receive replies to emails sent out from my holdenweb.com account in the Gmail mailbox I have used for years. At first I though this might be Thunderbird (or me) getting my email accounts and personalities mixed up, but it appears this isn't the case. Here's a test message I sent to myself as an experiment, as it looks in my Sent folder:
So it definitely looks as though it went out from holdenweb.com. And here's the same message as it arrived in my Inbox:
So it goes out from my holdenweb.com address, and arrived at the recipient from my gmail.com address. That's pretty evil, Google - or is there some obvious way I am shooting myself in the foot? It's making my mail conversations pretty hard to track right now.

PyCon is Coming


Kirby Urner suggested that the PSF should advertise PyCon at airports. I though this was a great idea until I looked into the cost of hiring the billboards. Thanks to the wonders of modern web technology, however, we can all now see what it would be like to advertise PyCon on buses.

My slogan is probably pretty feeble. Can you do better?

October 16, 2009

Pyticipate: Interpret Your World

Well, Grig Gheorghiu just posted the list of invited speakers for PyCon 2010, with their chosen topics. It's a doozie:

Ian Bicking: On the Subject of Source Code
Jeff Rush: Interfaces, Adapters and Factories
Jack Diederich: Python's Dusty Corners
Mike Fletcher: Debating 'til Dawn: Topics to Keep You Up All Night
Raymond Hettinger: Mastering Team Play: Four Powerful Examples of Composing Python Tools
Bob Ippolito: The Other Kind of Testing
Alex Martelli: Powerful Pythonic Patterns
Joe Gregorio
: Threading is Not a Model
Ned Batchelder: Tests and Testability
Holger Krekel: The Ring of Python
Ted Leung: A Survey of Concurrency Constructs

More details on the PyCon web site. If PyCon only had those talks it would make an amazing one-day event, but of course there will be three days of talks, with four tracks, so in practice it will be completely impossible for anyone to attend all the talks that they would like to.

That's where the Pycon videos come in - high quality recordings of every scheduled talk will be available. It's nowhere near as good as being there, but if you were at PyCon it's a great way to fill in the gaps, and if you weren't then it's a good reminder of exactly why you should be next time around.

PyCon is a great conference. I'm looking forward to it already!

September 27, 2009

Lending Pythonistas

Too often I hear people bemoaning their inability to change the world, so I wanted to bring Kiva, and specifically the Pythonistas team, to your attention because if you have even a modest amount of money to spare you can put it to use again and again to help worthy enterprises, typically closely allied with their local community.

I started lending money through Kiva a while ago, and more recently joined its Pythonistas team. I suggested starting such a team shortly after I joined Kiva, but it took Anna Martelli's energy to actually get it off the ground, and I received my invitation a couple of months ago - thanks, Anna! If you decide you want to become a "Kiva Pythonista" all you have to do is follow this link.

Even as a Kiva Pythonista you still decide to whom you want to lend money, you simply say you want your loans to be counted as a part of the Pythonista effort. The enterprises you will fund are typically far from hi-tech: here are some of the groups I am currently funding to give you some idea of the kinds of activity you can support.

Secretarial Services in Uganda
Second-Hand Clothing in Guatemala
Fish Retailing in Senegal
Cattle Farming in Azerbaijan
A Grocery Store in Cambodia
Animal Rearing in Tajikistan
A General Store in Togo
A Cooperative Bank in Bolivia

This came to mind because I got an email this morning reminding me that I had received repayments of $150, and so I am just about to use the Kiva site to lend those repaid funds to new borrowers, keeping my money actively at work. And now I can do it as a Pythonista!

September 23, 2009

Last Week to Submit Your PyCon Papers

PyCon is a little earlier next year, and the organizers are trying to prepare earlier too. So this is a reminder that there is one week remaining to submit your PyCon talk proposals. PyCon 2010, in Atlanta, is a must-attend event. It's a great event to speak at, too, so don't delay!

September 16, 2009

PyCon Talk Submissions Closing Soon

Please note that if you would like to present a talk at next year's PyCon, time is rapidly running out. The call for papers was issued some time ago, and closes on October 1. So get your writing hat on, and put that proposal in now!

September 15, 2009

Apple's Cynical Approach

It turns out that for a long time now Apple iPhones have been lying to Exchange Server mail hosts, telling the mail servers that on-device encryption is supported. It now transpires that only the recently-added 3G S model supports encryption through hardware, and this came to light when a recent upgrade made the phones tell the truth.

The unfortunate consequence for any business that has standardized on iPhones for remote mail access is that if they have required on-device encryption the iPhone has been breaking their security guidelines since it was installed. According to Apple their only alternatives are to change their security policies to allow iPhones to store plain text emails or upgrade everyone to the new 3G S device.

What a crock. Not only that, the iPhone users apparently had to wait until after they'd been upgraded to even learn that this issue existed. I am so glad I'm not a corporate Apple user.

September 9, 2009

Community Spirit

If the Python community (or the whole open source community, for that matter) could learn to work together for a common goal there's almost nothing it couldn't achieve. Here's an example of what single-minded determination can do.

August 29, 2009

Python in Brazil

If you want an exotic holiday, fly to Brazil. While you are there, take in the pythonbrasil conference. That's a good web site that makes it look like fun!

August 27, 2009

Can You Do Better?

As a graphic artist I'm a pretty good combine harvester operator, so there is no subtlety about the banner graphic I came up with for (maybe) the python.org homepage. But I was glad that Andrew Kuchling asked, because PyCon should be better known. If Python is the technical secret weapon then I believe PyCon is truly the social secret weapon. I know other projects are having good success with community conferences, and would like to have the time to visit some of our sibling foundations' events.

If you attend such an event you will be doing the Python community a service by writing it up for Planet Python. It's not hard to get your blog on the Planet if you do a few good Python posts, and we hear a lot more about the technical than the social normally.

Wow, next year it will be PyCon number eight. Three years after that will be the tenth anniversary of the very first PyCon. It would be terrific if we could go back to DC for that conference. What about it, DC metro area?

August 21, 2009

Bugzilla Bug?

Why, when you change the assignment of an issue in Bugzilla, doesn't the default status change to "Assigned"? I so often forget to make that change it's not funny.

August 17, 2009

Hono(u)r Alan Turing

Alan Turing was the greatest computer scientist ever born in Britain. He laid the foundations of computing, helped break the Nazi Enigma code and told us how to tell whether a machine could think.

The world might have benefited from his ideas considerably more had the prudish (and, as it turned out, probably hypocritical) authorities at the time not hounded him to an early grave because of his homosexuality.

We should think before we cast the first stone, as we do not know where the universe pivots.

This story has been considerably edited, as I must acknowledge the force of my critics' remarks. The original was intemperate and, well, unoriginal so I decided to remove the call to read and sign a petition and simply make my own statement about how Turing, one of the seminal intellectual leaders of the 20th century, was treated by an unthinking populace allowing the irresponsible authorities to act "in their name". The first paragraph is from the petition.

EveryBlock Acquired by MSNBC

News today from EveryBlock via Adrian Holovaty that the founders have agreed to let MSNBC acquire their company. Happily Adrian is on record already as expecting a completely unchanged relationship with Django and Python, pointing out that MSNBC is only half-owned by Microsoft.

August 15, 2009

Advertising the Competition

Someone asked me why the last two posts had highlighted "competing" classes.

This blog isn't here to sell training. It's a place to learn about training, among other things. Feel free to come here to learn about the competition's classes. It's this blog you're coming to, right?

If I only mentioned Holden Web's classes, and not Enthought's and David Beazley's (and ...), you probably wouldn't consider this blog quite such an impartial source. I don't think it hurts to be on good terms with the competition. It's the Python way, after all.

Python for Systems Hackers

Given by David Beazley, Chicago. 3 days, August 17-19 (next week). Details here.

Python Training for Scientists

[Disclosure: Enthought and Holden Web have discussed joint training plans in the past. No commercial agreements are currently in force.]

If you're a scientist and you want to use computers as more that just calculators then you just might want to learn Python. So you could take the Holden Web Introduction to Python class, or you could take two extra days and go to the Python for Scientists class at Enthought.

August 14, 2009

The Internet is Not the UK

Without the EFF Western society's relentless march towards 1984 would have concluded by now. Many formerly accepted liberties have been eroded in the first decade of the 21st century. Think about joining.

Burning Man Rip-Off?

Bother, and I was starting to think Burning Man might be worth attending. Looks like they need to get this silliness sorted out. Hardly appropriate in the 21st century. If I had a ticket they could even make me change this heading!

Which, since second thoughts are proverbially the best, I have done by adding a question mark; I also prefer "silliness" to the former"stupidity". A potentially offensive word was replaced.

Further edit: from the Burning Man web site:
"Use of Images"
I UNDERSTAND AND ACCEPT THAT NO USE OF IMAGES, FILM, OR VIDEO OBTAINED AT THE EVENT MAY BE MADE WITHOUT PRIOR WRITTEN PERMISSION FROM BURNING MAN, OTHER THAN PERSONAL USE. I understand that I have no rights to make any non-personal use of any image, film, or video footage obtained at the event, and that I cannot sell, transfer, or give the footage or completed film or video to any other party, except for personal use, and I agree to inform anyone to whom I give any footage, film, or video that it can only be used for personal use.

August 13, 2009

PyCon 2010 Call for Papers

From Jesse Noller and his colleagues on the PyCon 2010 Program Committee comes the following message. Please consider submitting one or more presentations. PyCon is the largest Python conference in the world, and delegates have a fabulous time.

Call for proposals -- PyCon 2010 -- http://us.pycon.org/2010/

Due date: October 1st, 2009

Want to showcase your skills as a Python Hacker? Want to have
hundreds of people see your talk on the subject of your choice? Have some
hot button issue you think the community needs to address, or have some
package, code or project you simply love talking about? Want to launch
your master plan to take over the world with python?

PyCon is your platform for getting the word out and teaching something
new to hundreds of people, face to face.

Previous PyCon conferences have had a broad range of presentations,
from reports on academic and commercial projects, tutorials on a broad
range of subjects and case studies. All conference speakers are volunteers
and come from a myriad of backgrounds. Some are new speakers, some
are old speakers. Everyone is welcome so bring your passion and your
code! We're looking to you to help us top the previous years of success
PyCon has had.

PyCon 2010 is looking for proposals to fill the formal presentation tracks.
The PyCon conference days will be February 19-22, 2010 in Atlanta,
Georgia, preceded by the tutorial days (February 17-18), and followed
by four days of development sprints (February 22-25).

Online proposal submission is open now! Proposals will be accepted
through October 1st, with acceptance notifications coming out on
November 15th. For the detailed call for proposals, please see:

http://us.pycon.org/2010/conference/proposals/

For videos of talks from previous years - check out:

http://pycon.blip.tv

- Hide quoted text -
We look forward to seeing you in Atlanta!

August 10, 2009

People Using Python

The Python Software Foundation has embarked on a mission to find out more about Python users. We want to know as much about the organizations that use Python as possible. If you want to give us information about any Python usage at all (even organizations other than the one you work for) please fill out this form. We don't even need your details, and we'll filter for duplicates.

So please help us to find out as much as we can about who's using Python, and what for!

Google Sorry

Quite why Google Documents should be giving me this message when Gmail, Blogger, YouTube and various other Google services are all working normally I have no idea. This is particularly frustrating since it's OK for me to look at "documents" and "files", but apparently when it comes to "spreadsheets" I am a botnet and not to be trusted.

Clearly I'm on some sort of blacklist. For how long, who knows? This has been going on for four hours now. And one of the frustrating things about using Google's services is that it's absolutely impossible to get a human being to tell you what the heck is going on, or take some action about it. You can rely too much on automation (but hey, it keeps the margins up).

Going to rethink this one. The document I can't get access to is the PyCon 2010 budget. Google sorry? Google FAIL.

August 4, 2009

Who Put the "Ass" in Associated Press?

The recently-publicized Associated Press approach to copyrighting the news includes such stupidities as
To this stupidity it appears that through the inadequacies of the system they have chosen to use for licensing we can now add
  • Charging people for things that were never said:
This does raise some interesting questions, however. Since I now have a license (purchased for $12.50) from Associated Press to quote these words, are they going to sue me for defamation (against which my defense would be "fair comment") or will they instead fall back on their terms of use, which does not allow me to use licensed material in a way "derogatory to Publisher"?

Given the huge popularity of this blog (not) I suspect this one will sneak under their radar, but if it doesn't (and assuming I am neither subjected to a gag order nor rubbed out by hired gorillas) I shall report back.

UPDATE: About five hours later I received a refund on the grounds that the quoted material was not part of the referenced article:
So it appears that the system isn't quite as asinine as it might at first seem. But Associated Press still need to get a clue, I think.

July 12, 2009

PSF Associate Memberships?

When I spoke about The PSF and Us at EuroPython a couple of weeks ago there were some interesting questions, many of which related to how individuals could help the Python Software Foundation. During the discussion I asked how many people would be prepared to support the Foundation by paying for some kind of (non-voting) associate membership, and I estimate at least half the audience's hands were raised.

It appears, therefore, that Python users want to be associated with the Foundation. So now I would like to ask readers (whom I assume will mostly be Python users) a few questions.

Do you think it would be a good idea for the PSF to broaden its membership base in this way? If you aren't a nominated member, would you like to become an associate? If so, why? What would you like to get from an associate membership? What could the Foundation offer in return for some annual payment? What should that payment be? What could (or should) the Foundation be doing for you and Python that it isn't already?

I am looking for some guidance here from an apparently under-served section of the Python community. Your feedback will be invaluable.

June 27, 2009

Another United Web Screw-Up

So, wanting to answer a question about my flight times for EuroPython I clicked on an email link to "My Itineraries". Thanks, United, this couldn't be clearer.

June 23, 2009

My God, I Have Fans

I've been putting out links on delicious.com for a while now (when I started it was del.icio.us, which I personally still prefer as a domain name, though probably it was too esoteric for the non-geeks). It's a great system, and I have a program that searches my feed for the last seven items I tagged with "python" and makes those the front-page news item on holdenweb.com.

Most of my interactions with delicious go through the Firefox add-on, so I was a little surprised today to discover that my delicious network page shows that my feed has 44 fans. This means I now have a bunch of feeds to start looking at. I am going to have to stop sleeping ...

Looking at the network page I was also quite interested to see the top 10 tags list of the things I have tagged most frequently.

python 194
web 96
programming 80
design 71
development 58
tools< 49
politics 46
webdesign 44
marketing 40
open< 40

That gives you a fair idea of my interests. Don't tell Guido about the marketing ...

June 19, 2009

June 18, 2009

Technology for Keeping People Honest?

Simon Willison and his team at the Guardian in the UK have brought a dream a step nearer to becoming true for me with his new Investigate Your MP's Expenses site. After looking at government profligacy in the USA I decided the only thing to do was to open up public accounts to public scrutiny.

Simon's site (quite independently conceived) is a practical demonstration of the idea's feasibility on a large scale. All we need now is a sponsor with deep pockets and an interface to Mechanical Turk. The next election is going to be interesting.

June 17, 2009

Seth Godin Says A Mouthful

You will probably be aware if you are a regular reader that while I'm not wild about marketing generally, I do see value in some things some marketers do and say. Seth Godin had a blog post recently called You Matter that describes quite well the kind of spirit I want to foster in the Python community.

As tummy.com said on their PyCon sticker this year: "Python will save the world! I don't know how, but it will." Isn't it up to us all to help Python do that?

June 11, 2009

Ubuntu 9.04 Wireless on Dell Precision M6300

The best laid plans of mice and men have yet again gone agley. For a couple of years now I have been running Vista on my Precision workstation. In order to move to the Linux platform I bought a 320 GB 2.5" disk (amazing value at $90) and planned to install Ubuntu Jaunty Jackalope on it then migrate the Vista disk to a VirtualBox virtual machine accessing a raw patition which contained a Ghost copy of the original Windows partition.

Alas I couldn't get the virtual to boot, and anyway the Vista load is starting to show signs of instability (hardly surprising in a Windows installation that's been poked and prodded as heavily as mine has), so I have bitten the bullet and am reinstalling Vista from scratch with a virtual filesystem. The partition that was going to host Vista is now an ext4 filsystem which can host whatever I want or need to put on it. I have installed VirtualBox, and Vista loaded up like a champ.

The only (current) fly in the ointment is that for the life of me I can't get wireless networking to work. Unfortunately Command Line Idiot appears to be right when he or she writes:
There are roughly 19 billion tutorials for how to do anything you would ever want to do with Ubuntu. Unfortunately, they are all written by a 12 year old who knows even less than you.
Some of the advice I have seen is so cryptic as to be incomprehensible, some refer to drivers I don't have and don't seem to be able to download, the majority of it its either apparently irrelevant or clearly wrong.

So, crazy fundamentalist or not, I'll be happy to hear from you if you can tell me how to get the wireless networking going.

June 10, 2009

Not My Day with Microsoft

Well, I guess I won't be downloading SharePoint Designer just yet, then ... even the best-run and largest organizations have problems.

You know, I really wish the free software/open source world would come up with something as easy and effective as SharePoint. Maybe it will soon. SharePoint has become as popular as it is (and it's making Microsoft over $1 billion a year now) because, like Office, it's broad enough to meet the majority of most people's needs.

It's complex, but not really complicated, and I know it's not beyond the skills of the free software/open source community. Support, of course, would be something else. Now that would be a company I'd like to start ...

June 5, 2009

Google Wave: A Reason to Learn Java?

I've just (finally!) finished viewing the developer preview video of Google's Wave project from the recent Google I/O gathering. If I had time I would be brushing up my Java right now. I understand that the Java world was somewhat upset that Google App Engine supported only Python as a programming language for so long. Well, Wave is based on the Google Web Toolkit (GWT), a fascinating development platform that allows you to program in Java and deliver AJAX applications automatically translated (on the client side) into JavaScript. So now it's time for us Python guys to stand in line.

Wave is an amazing demonstration of where the web is going, and our lives are going to be richer for it. It's an entirely new approach to personal communication, and clearly demonstrates that open architectures are (pun intended) the wave of the future. Google are actively looking for people to get involved with the project already.

More later. For now I am too blown away to do much more than sit here thinking about the potential. I am also excited that this represents a bundle of opportunities for the open source world to demonstrate technical leadership. Unless other vendors have come up with some competing web-based technology I'm not aware of, and I'd be happy to learn about that too.

Information about the Wave platform (and, of course, the open source code) is on Google Code. The open Wave protocol details are on a separate site. Look for Wave's public arrival later in the year. Nice job, Google.

June 3, 2009

Something Smells

If you were at PyCon you probably noticed that netbooks are becoming more popular. PyCon delegates being geeks, I don't remember seeing a single one that wasn't running some form of Linux, though Microsoft do support the little machines with Windows XP. This in itself is an admission that Vista, their current operating system, is a resource hog. As a Vista user all I am prepared to say is "get me out of here", though the day-to-day experience is made bearable [short pause while all applications lock up for 90 seconds and the disk hammers away madly at I know not what] by the (open source) Cygwin command shell and the (open source) VirtualBox virtual machine that lets me operate virtual Linux hosts.

I don't have a netbook yet (though I have already bought one for my wife), but it's only a matter of time. I currently lug 6.6 pounds of laptop around with me for the large 17" screen that I find useful for development and the 4GB of memory, which was a lot for a laptop a couple of years ago. I may extend the life of the machine by upsizing the drive to 500GB, but I definitely want my next portable machine to be lighter, and lighter means smaller (though nowadays not necessarily much less powerful). In other words, it's the coming trend.

The manufacturers (who are all in the far East, naturally) have detected this trend, and are pushing out new hardware faster than a sow can push piglets. All of this new hardware can run at least three different operating systems: Linux, Windows and Android. Users have been expressing their discontent with the higher price of Windows systems in the desktop market, but didn't have a lot of alternative. However, Microsoft realized that if they charged their usual premium for Windows XP on the netbooks people would just laugh and buy a system with one of the alternatives loaded.

So the bottom line is that Microsoft are almost giving XP away (and why wouldn't they, the money it's already made them) just as a damage-control measure. It's vital to Microsoft that Linux and Android aren't seen as viable alternatives to Windows, particularly since the beta program of Windows 7 is making it seem like an operating system whose principal selling-point is the ability to switch its features off.

Enter the Taiwanese Computex trade show that opened yesterday. Qualcomm were showing a new Asus netbook running the Android operating system, but on the Asus stand there was no sign at all of this startling new development. In fact Asustek's vice chairman John Tsang said, shortly after sharing the stage with Intel and Microsoft representatives, that the Android notebook was not a priority. Android still has a way to go to be totally user-friendly on a netbook, but if Qualcomm could show it, why couldn't Asus? Were they, perhaps, being polite to a major business partner?

The UK PCWorld chain also said it is stopping selling anything but Windows through itsbricks-and-mortar stores, though mail-order buyers still have the Linux option. When I see press releases like that I am always intrigued about whether they are induced purely by market forces or whether some backroom maneuvering isn't involved.

One thing's certain. No matter what they have done for Mac sales, Apple's long-running TV adverts have positioned Windows (synonymous in the public mind with "PC") as an unstable, unreliable, bug-ridden inconvenient platform. Now it's beginning to look as though the hardware industry is becoming more independent of Microsoft for the software necessary to run its devices, which I see as a good thing.

Microsoft stockholders may, of course, disagree. I wouldn't necessarily sell your Microsoft stock right now. Just don't buy too much more.

May 31, 2009

PyCon is Popular!

Regular readers will know that this year's PyCon went extremely well. Not only was it excellent value for money, but we finally got our video recording act together, to the point where most sessions' video was available on blip.tv less than a week after the end of the conference.

I just learned that there have already been over 180,000 views of the material since it was uploaded roughly two months ago, which works out at around 3,000 per day. It just goes to show that there is a lot of demand for material about Python!

May 29, 2009

Where Next for PyCon?

PyCon 2010 will be in Atlanta, as I wrote a few weeks ago. No decision has been made about future venues, but given yesterday's release of the PyCon 2009 delegate questionnaire response data I thought it might be instructive to use Python to try and get a handle on public opinion about future locations. Question 13 asked "Where would you like to see PyCon 2010 or a future PyCon? Enter up to 3 cities or regions."

I copied the data into a spreadsheet for ease of manipulation, and did some munging to standardize presentation. I may have taken a few liberties here (such as replacing "California, Bay Area" with "San Francisco"), but I did so in an honest attempt to make sure that every important datum was counted. If the conference were to go to "San Francisco" the organizers would be very foolish to overlook other potential Bay Area locations, for example.

The Data
You can find the raw data I ended up with at http://holdenweb.com/files/wherenext.txt if you want to play about with them yourself. Here's a small section to give you the flavor:
New Jersey      Palm Springs    "Portland, OR"
New York "Portland, OR" "Portland, OR"
New York "Portland, OR" "Portland, OR"
New York "Portland, OR" San Diego
Northeast "Portland, OR" San Diego
Nowhere specific "Portland, OR" San Francisco
Phoenix Saint Paul San Francisco
"Portland, OR" San Francisco Seattle
It's simple tab-separated data, with gratuitous quote marks from Excel. The presentation makes it look like everyone made first second and third choices that were suspiciously close together in the alphabet, but that's only because I sorted each column independently to make the munging easier. I should probably have used the csv module to read the data, but foolishly chose to do it myself. Just the same, there isn't a lot of code.

The Program
#!/usr/bin/python
#
# Process PyCon feedback about future venues
#
# NOTE: Food for thought only ...
#
pd = {}
f = open("wherenext.txt")
for line in f:
places = [p.strip('"') for p in line.strip().split("\t")]
for rank, where in enumerate(places):
if not where in pd:
pd[where] = [0, 0, 0]
if where:
pd[where][rank] += 1

places = []
for where, [w1, w2, w3] in pd.items():
places.append((3*w1+2*w2+w3, where, [w1, w2, w3]))
for rank, where, scores in sorted(places):
print where, rank, scores
The first for loop simply iterates over the file. Each place's position in the line is the weighting that a voter gave it, so after splitting the line at each tab and removing any leading or trailing quotes I then use enumerate() to generate (rank, placename) pairs for all elements in the line. Some lines have only one or two entries because not everyone made three choices, but the formulation I used copes fine with that.

The placename of each pair is used to index a dict of [first, second, third] counts which counts the number of times a specific place was ranked in each position.

The next for loop is my favorite piece of this little program. It generates a new list of (weighted_score, placename, raw_scores) tuples ready to be sorted. The weightings I used (3 for a first choice, 2 for a second and 1 for a third) were completely arbitrary, so feel freee to change them in an attemto to fudge the results for your favored location.

Why did I like this particular loop so much? Since each item in the dict is a (placename, raw_scores) tuple I unpack the elements right in the for statement. It's such little elegances that endear Python to its fans: you can always do things in a straightforward way if you want, but as long as it doesn't interfere with readability I usually take advantage of such abbreviations.

I felt that a list comprehension would have been just a little bit too difficult to read, but you could easily replace the loop with one, and for further illegibility you could put it directly as the argument to sorted().

Finally I print out the results, with the lowest scoring first. Yes, I could have used a reverse() call to print out the favorite first, but then I'd have had to scroll the window back to know which city had "won". I could have formatted them better, too. Feel free, knock yourself out. I try to avoid over-specifying presentation when it's really the data I am interested in.

The Results
Given that the 2009 conference was held in Chicago I was unsurprised to see a strong vote for it, presumably by locals who might not be able to get to Atlanta, and certainly wouldn't find it as convenient. The only surprise was that it came in second rather than first! Portland, OR made a very strong showing, scoring only two points less, closely followed by Seattle with New York and Washington DC trailing rather further behind, But the clear winner was San Francisco, by coincidence the other location to make a strong bid for 2010 with Atlanta. Here are the results in their entirety.

Please remember that the data is from a self-selected group, and that this program is not binding on the PyCon organizers! Despite my best efforts I must have left a blank line in the data, so the empty string is recorded as having no scores! The if where condition should really have guarded the whole loop body, but it was an afterthought, and serves to remind us that sloppy design will lead to sub-optimal results.

0 [0, 0, 0]
Bay Area, CA 1 [0, 0, 1]
Cleveland 1 [0, 0, 1]
Houston, Texas 1 [0, 0, 1]
Knoxville, TN 1 [0, 0, 1]
Midwest 1 [0, 0, 1]
Oregon 1 [0, 0, 1]
Orlando, FL 1 [0, 0, 1]
Phoenix, Az 1 [0, 0, 1]
Pittsburgh, PA 1 [0, 0, 1]
Portland, ME 1 [0, 0, 1]
Twin Cities, MN 1 [0, 0, 1]
Virgin Islands 1 [0, 0, 1]
West coast 1 [0, 0, 1]
not next to an airport 1 [0, 0, 1]
vancouver 1 [0, 0, 1]
Boston Area 2 [0, 1, 0]
Cleveland, OH 2 [0, 1, 0]
East coast 2 [0, 1, 0]
Fort Collins, CO 2 [0, 1, 0]
Honalulu, HI 2 [0, 1, 0]
Kansas City, MO 2 [0, 1, 0]
Las Vegas, NV 2 [0, 1, 0]
Lawrence, Kansas 2 [0, 1, 0]
Los Angeles, CA 2 [0, 0, 2]
Manhattan 2 [0, 1, 0]
Minnesota 2 [0, 1, 0]
New York, NY 2 [0, 1, 0]
Palm Springs 2 [0, 1, 0]
Saint Paul 2 [0, 1, 0]
San Diego 2 [0, 0, 2]
Seatle 2 [0, 1, 0]
Toronto, ON 2 [0, 1, 0]
Vegas 2 [0, 1, 0]
huntsville, al 2 [0, 1, 0]
new orleans 2 [0, 1, 0]
Detroit, MI 3 [1, 0, 0]
East Coast 3 [1, 0, 0]
Europe 3 [1, 0, 0]
Houston, TX 3 [1, 0, 0]
Huntsville, AL 3 [1, 0, 0]
Kansas City 3 [1, 0, 0]
Madison, WI 3 [1, 0, 0]
Miami 3 [1, 0, 0]
Montreal 3 [1, 0, 0]
New Jersey 3 [1, 0, 0]
Nowhere specific 3 [1, 0, 0]
Phoenix 3 [1, 0, 0]
Raleigh/Durham, NC 3 [1, 0, 0]
Reno, NV 3 [1, 0, 0]
San Diego , CA 3 [1, 0, 0]
San Fransisco 3 [1, 0, 0]
San Jose 3 [1, 0, 0]
St. Louis, MO 3 [1, 0, 0]
Tucson, AZ 3 [1, 0, 0]
london 3 [1, 0, 0]
New Orleans 4 [0, 2, 0]
Colorado 5 [1, 1, 0]
Northeast 5 [1, 1, 0]
Canada 6 [2, 0, 0]
Las Vegas 6 [1, 0, 3]
Somewhere hot 6 [1, 1, 1]
Vancouver 6 [0, 3, 0]
Dallas, TX 7 [1, 2, 0]
Denver 7 [1, 2, 0]
Minneapolis 7 [2, 0, 1]
Toronto 7 [2, 0, 1]
California 9 [3, 0, 0]
Atlanta 10 [2, 2, 0]
Austin, TX 14 [1, 5, 1]
Boston 16 [2, 2, 6]
Washington, DC 16 [4, 2, 0]
New York 19 [3, 4, 2]
Seattle 27 [3, 7, 4]
Portland, OR 35 [5, 5, 10]
Chicago 37 [10, 2, 3]
San Francisco 45 [11, 5, 2]

May 25, 2009

Memorial Day

No matter what you think about the US's current wars (and I think they are an abomination) one can have only the utmost respect for those who choose to serve their country in the armed forces. This post is published as an expression of my admiration for the country's servicemen and women, with sympathy and deepest condolences to all families whose loved ones have been lost in action.

May 22, 2009

EuroPython Booked

So the flights and hotel are booked and it's confirmed: I am going to EuroPython. This will only be my second attendance, and since it's in England this year close to where my one of my sisters lives I expect to feel reasonably at home. It won't be a long trip, but John Pinner tells me he'd like me to give a talk about the PSF and an after-dinner speech, and that "we may like you to join a panel or two, Open Space etc as well if that's OK".

Since the conference is paying my travel and accommodation it would seem ungracious to refuse. So it looks like I'll be busy. I am already looking forward to it!

One of the nice parts of visiting the Midlands will be a chance to sample some British beers. If you have any recommendations or suggestions please be sure to let me know!

May 21, 2009

Trying Again

I believe my typesetting confusion of recent days was due not, as I had feared, to my advancing years and inability to solve technical problems, but rather to a discrepancy between Blogger's preview and the final display of the blog, plus the absence of div tags.

The output of the program in Blogging Python Output: A Challenge should have displayed as
<__main__.MyCls object at 0x024217F0>
Let's see if this survives being saved and published, as so few have before it.

Factory Functions

In the last entry we discussed passing callables (using functions and classes) as arguments to functions, and calling them within the body of the function. This time we'll look at how functions can return more esoteric objects - again including functions and classes.

Beginners sometimes ask how a function can be made to return "more than one object". The strict answer is that it can't. The single object it returns can be a container, though, allowing several values to be extracted from the returned object. If you want a function to return three values the easiest way to arrange this is to have it return a three-element tuple, and then extract the individual values using an unpacking assignment. Here's a simple example.
def powers(a):
return a, a*a, a*a*a

a, square, cube = powers(10)
print(a, square, cube)
This prints 10 100 1000, showing that the three returned values have indeed been assigned to individual variables. Functions can return more complex objects than simple containers, though. A frequent example in the programming literature is a function that returns some newly-created function each time it is called. Typically the function returned will vary according to one or more of the arguments passed to the call that creates it.
def make_fun(power, debug=False):
def pow(x):
result = x ** power
if debug:
print("power(%s, %s) returned" % (x, power), result)
return result
return pow

squarer = make_fun(2)
cuber = make_fun(3, True)

print([f(9) for f in (squarer, cuber)])
A call to make_fun() results in a function being defined as make_fun's function body is being executed. This function (whose local name is pow) contains references to the arguments passed to make_fun, and is returned by the call to make_fun to be assigned and eventually called. The calls to the function are inside a list comprehension just because that's the easiest way to call a set of functions with the same argument(s).

The output from this is
power(9, 3) returned 729
[81, 729]
The debugging output from cuber is seen before the list comprehension because all calls have to return their values before the list comprehension is complete and ready for printing.

You may be familiar with the concept of a mixin class. Such classes are designed to take advantage of Python's multiple inheritance features to add functionality to any chosen classes, by creating a new class which is a subclass of both the mixin and the chosen class. You can see an exellent example of this in the socket library, where a ThreadingMixIn class is defined and can be used to extend the features of the basic UDPServer class like this:
class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
Note that the newly-declared ThreadingUDPServer class doesn't specify any behavior of its own, it merely inherits - first from the mixin and then from the base class, meaning that methods defined in the mixin take precedence over those defined in the base server class. One problem with this, however, is that it doesn't allow for any variation in the mixin classes - by the time you use them they are already created, and it's too late.

In the same way that we can parameterize functions, however, we can parameterize classes as well. Suppose we want to provide a trivial mixin to print the class's name in either upper- or lower-case. Not very inspiring, but the simplest example I could think of to get the point over, so please bear with me if you can think of simpler ways to do this. One possibility is this.
def mixin(cls, lcase=True):
class Mixin:
def nprint(self):
if lcase:
print(str(cls).lower())
else:
print(str(cls).upper())
class Result(Mixin, cls):
pass
return Result

class FirstClass:
pass

Cl1 = mixin(FirstClass, True)
cl1 = Cl1()
cl1.nprint()

mixin(FirstClass, False)().nprint()

Here the function first defines a mixin class, then creates a new class from the mixin and the base class provided as an argument. The interpreter cares not at all where the class definitions come from - classes are first-class objects just like functions and strings, and can just as easily be passed as function arguments as obtained any other way.

The output from the program, which I am sure you are waiting for with bated breath, is
<class '__main__.firstclass'>
<CLASS '__MAIN__.FIRSTCLASS'>
which shows that the program runs, and that the mixin class's behavior is conditioned by the function's second argument.

Now you might choose to argue that this isn't a very natural example, and I'd be inclined to agree with you. All I have to say besides that is, you try coming up with these examples and see how you like it. If anyone chooses to contribute a more natural example that can be expressed without too much extra code I'll be happy to write about it.