Archive for September, 2010

Some people learn through doing it, others are better with visual stimuli. At least, that’s what we’re told. So in the spirit of what we’ve been taught, we’re going to take a look at the visual half of the equation and see how we can make graphs with wxPython. You may not know this, but wxPython includes a widget just for this purpose. It’s name is PyPlot. PyPlot is great at doing simple plots and it’s super fast too! If you need to weird or complicated plotting, then you’ll want to use matplotlib instead. Fortunately, wxPython and matplotlib play well with each other, but we won’t be looking at matplotlib in this article. (more…)

Jesse Noller just put out the call for proposals for PyCon 2011. That means that you have the chance to give a talk to a whole bunch of geeky pythonistas! Get your thinking caps out and put those suckers on! If I go this year, I want to see some amazing and interesting talks so get on it you guys (and girls)! For the full monty, check this page out:

http://us.pycon.org/2011/speaker/proposals/

I’ve been thinking that it would rock if this website had a cool logo or artwork of some sort. So I thought I would create a contest to allow my talented readers a chance to help me out here. Here’s what I’m looking for:

  • Some kind of banner or background picture
  • A mouse (the furry kind, computer mouse, mecha or whatever) going up against a Python (or other cool snake). It can be realistic, cartooney, surreal, etc.

The artwork would be used on my blog and I’d put it on shirts and other items on a Zazzle-type account, cross-linked to my blog. The art will go under the Creative Commons Attribution-ShareAlike 3.0 Unported license.

Here’s what the lucky winners get:

First Prize

  • $100 Amazon gift certificate
  • Practical Programming: An Introduction to Computer Science Using Python
  • Attribution on my blog and links to the artist’s website(s)

Second Prize

  • $50 Amazon gift certificate
  • Attribution on my blog and links to the artist’s website(s)

Yes, I know it’s not much, but this is coming out of my own pocket and I’m no corporate bigwig. For those of you interested in statistics, this blog generates around 21000 page views a month with approx. 12-14000 visitors.

Email your submissions to contest@pythonlibrary.org. Submissions should be no larger than 10 MB. Contest ends October 31, 2010 at 11:59 p.m. Central Standard Time. I am the sole judge and will choose the two submissions I like best.

This week, I finished editing another book for Packt Publishing. The book’s name is Python Graphics Cookbook by Mike Ohlson de Fine (I think). You may wonder why I don’t know if de Fine is the author. Well, Packt thinks that its Technical Editors shouldn’t know that information. In fact, Packt is so cagey (and stupid) that they’ll give us forms to fill out asking us for the ISBN of the book we’re reviewing, but refuse to give us the ISBN.

Let it be known that Technical Reviewers for Packt Publishing are paid absolutely nothing. The only remuneration we get is a copy of the book we review, plus another book of our choice and our name/bio appears in the book we reviewed. That’s it. If Packt approaches you, let this be a warning to you.

Now, it’s not all bad. You get to read a book before almost everyone else AND you even get to help shape the book! That’s really cool! However, if you don’t read quickly, then this job is not for you. You usually only get 3 or 4 days to review a chapter. But enough of my whining, let’s get on with the Preview! (more…)

Back in March of this year, I wrote a simple tutorial on Reportlab, a handy 3rd party Python package that allows the developer to create PDFs programmatically. Recently, I received a request to cover how to do tables in Reportlab. Since my Reportlab article is so popular, I figured it was probably worth the trouble to figure out tables. In this article, I will attempt to show you the basics of inserting tables into Reportlab generated PDFs. (more…)

The other day, I received a complaint that my original notebook example in my Book control series was too complicated. I don’t really write just n00b-friendly articles and never claimed to, but this comment rankled, so I decided to write a super simple example for the wxPython newbies. I hope you like it! (more…)

Accessing databases with Python is a simple process. Python even provides a sqlite database library that’s built into the main distribution (since 2.5). My favorite way to access databases with Python is to use the 3rd party package, SqlAlchemy. SqlAlchemy is an object-relational mapper (ORM), which means that it takes SQL constructs and makes them more like the target language. In this case, you end up using Python syntax to execute SQL rather than straight SQL and you can use the same code to access multiple database backends (if you’re careful).

In this article, we’re going to look at how to use SqlAlchemy to connect to pre-existing databases. If my experience is any indication, you’ll probably be spending more time working with databases that you didn’t create than with ones that you did. This article will show you how to connect to them. (more…)

After about a year or so at my current job, as we were still working on upgrading the last few Windows 98 machines to Windows XP, we had a need to check which machines on our network were getting low on disk space. The issue was cropping up because we had Windows XP loaded on several machines that had 10 GB hard drives and a few with 20 GB and one or two with just 4 GB. Anyway, after some digging online, I discovered that the PyWin32 package could accomplish what I needed. (more…)

When I began learning Python, one of the first things I needed to know how to do was open a file. Now, the term “open a file” can mean different things depending on the context. Sometimes it means to actually open the file with Python and read from it, like with a text file. Other times, it means “to open the file in its default program”; and sometimes it means, “open the file in the program I specify”. So, when you go looking for how to do the latter two, you need to know how to ask Google just the right question or all you’ll end up with is learning how to open and read a text file.

In this article, we’re going to cover all three and we’ll also show how to open (or run) programs that are already installed on your PC. Why? Because that topic is also one of the first things I needed to learn and it uses some of the same techniques. (more…)

This is for all you Pyowa home-boys out there what missed our gathering. We don’t know why you homebodies didn’t come and hang out and talk shop wit us, but we think you really truly missed out on our phat gathering. We had around 10 real homies show up to hear the jibber jabber about South, a Django data migration tool. We were supposed to hear about SWIG too, but ended up swigging pop (or soda for you southerners) and chowing down on free pizza instead.

Next time, we’ll be booking it at the Ames Public Library in (you guessed it!) Ames, IA on Thursday, October 7th. If you think you got the chops for talking about Python, drop me a line and I’ll hook you up.