Entries tagged with “Python”.
Did you find what you wanted?
Tue 30 Apr 2013
If you have followed this blog for a while, you may remember that we’ve covered several XML parsing libraries that are included with Python. In this article, we’ll be continuing that series by taking a quick look at the ElementTree library. You will learn how to create an XML file, edit XML and parse the XML. For comparison’s sake, we’ll use the same XML we used in the previous minidom article to illustrate the differences between using minidom and ElementTree. Here is the original XML:
< ?xml version="1.0" ?>
<zappointments reminder="15">
<appointment>
<begin>1181251680</begin>
<uid>040000008200E000</uid>
<alarmtime>1181572063</alarmtime>
<state></state>
<location></location>
<duration>1800</duration>
<subject>Bring pizza home</subject>
</appointment>
</zappointments>
Now let’s dig into the Python! (more…)
Fri 26 Apr 2013
When I was a kid, I was really into secret codes and ciphers. I thought they were all kinds of fun. My mom thought it would be fun to use some of the ciphers I was so enamored with in treasure hunts for special occasions, like birthdays. She would take something like a Cryptograph Wheel and create codes with it that my brother and I would have to decode with our own wheel to find a gift or another clue. We used stuff where numbers would represent letters (a=1, b=2, c=3) or we would use a sliding scale where you move the alphabet one letter over so A=B, C=D, D=E, etc. Sometimes we’d create a code stick where you get a long string of paper and wrap it around a pencil and then write a message of the paper. It’s pretty much impossible to read when it’s unwrapped.
Anyway, I decided to create a silly cipher program with wxPython where I could input a string and have it convert it to something else. I also wanted my program to decode it too. Now you can’t really make a program that can use a Cryptograph Wheel or a code stick, but for number codes or slide scales, that’s extremely easy. (more…)
Fri 19 Apr 2013
Posted by Mike under Books, Python
[7] Comments
I recently received my copy of Real Python by Fletcher Heisler and just finished reading it. I got it as a bonus from a recent KickStarter campaign for the sequel to the book, Real Python for Web Development which is actually written by someone else. You can go to the book’s website to purchase the book and get access to the files that the book talks about. I’ll be reviewing revision 2.2, as that was what I got when I downloaded it a couple weeks ago. It appears that there’s been an update since then though. This is the first Python book I’ve ever read that focuses on Python 2.7.3, although it does mention some differences in Python 3 as it goes along.
Quick Review
- Why I picked it up: I got this book as part of the perks received from its sequel’s Kickstarter campaign.
- Why I finished it: The book had an engaging writing style
- I’d give it to: Programmers new to the Python language
If that intro interested you at all, feel free to join me after the jump to read the full review! (more…)
Tue 16 Apr 2013
The PySide GUI toolkit for Python has several standard dialogs and message boxes that you can use as-is. You can also create custom dialogs, but we’ll be saving that for a future article. In this post, we will cover the following dialogs:
- Color Dialog
- File Dialog
- Font Dialog
- Input Dialog
- Print & Print Preview Dialogs
We will also cover PySide’s Message Boxes. All code in this article was tested on Windows 7 Professional with PySide 1.2.2 and Python 2.6.6. Now let’s get to it! (more…)
Tue 16 Apr 2013
Posted by Mike under Advocacy, Python
1 Comment
I had heard about the Python Brochure Project last year but was under the impression that it was for corporations at that time as it seemed that you had to purchase them. It looked really good, but since I wasn’t a corporation and couldn’t buy them in bulk, I didn’t give it too much thought. However the Python Software Foundation has now released a preview of the brochure that’s worth a look. The brochure is for the marketing of Python, primarily for non-technical people (such as managers). If you’ve been struggling to get Python adopted at your place of work, this brochure might help as it showcases how Python is used in business in various fields from industry and science to education and government.
You can download it from their website and take a look. I thought it was pretty slick. You can even submit your own case studies to be included or help sponsor the brochure. Go check it out and spread the word!
Wed 10 Apr 2013
As I learn PyQt and PySide, I am writing some tutorials to help my fellow travelers. Today we’ll be looking at how to connect multiple widgets to the same slot. In other words, we’ll be binding the widgets signals (basically events) to slots (i.e. callables like functions, methods) which are better known as “event handlers”. Yes, I know in PySide land that you don’t call it that. It’s a SLOT, not an event handler. But I digress. Anyway, there are two ways to approach this. One is to use functools and its partial class to pass parameters or to use PySide’s introspection abilities to grab that information from the widget that did the calling. There’s actually at least one other method that is very similar to functools.partial and that is to use the infamous anonymous function utility known as lambda. Let’s take a look at how all these methods can be done! (more…)
Tue 9 Apr 2013
I am currently reading through Mark Summerfield’s book on PyQt, Rapid GUI Programming with Python and Qt and thought it would be fun to take some of the example applications in it and convert them to PySide. So I’ll be creating a series of articles where I’ll show the original PyQt examples from the book and then convert them to PySide and probably add something of my own to the code. The book doesn’t really get in Qt GUI coding until chapter 4 where the author creates a fun little currency converter. Come along and enjoy the fun! (more…)
Wed 3 Apr 2013
Posted by Mike under Books, Python
No Comments
Last week, Matt Harrison sent me a copy of his latest Python eBook entitled Treading on Python Vol 2: Intermediate Python. I was intrigued since I rarely get to read Intermediate level Python books. In fact, I would say that some of the stuff that the author talks about goes into the advanced level. Anyway, I thought it was a pretty good little book and if you have a moment, I’ll tell you why.
Quick Review
- Why I picked it up: As I mentioned, the fact that it was an intermediate level book made this a must-read for me.
- Why I finished it: Because the book proved to be very interesting.
- I’d give it to: Python programmers who have a good understanding of the basics but are looking to grow in their Python skills.
Now if you have a few more minutes, you can read my full review after the jump! (more…)
Mon 1 Apr 2013
Posted by Mike under Books, Python
[5] Comments
A couple months ago, I was contacted by John Rowland. He is the author of the brand new eBook Learn Python Quickly and he was contacting me about using one of my blog articles as the basis for one of his examples in his book. This one to be exact. Anyway, I told him I would review his book when it came out. Anyway, the book came out a couple weeks ago and here is my review. Note: I managed to snag a copy of this when it was free, which was the second day it was on sale, I think.
Quick Review
- Why I picked it up: I picked this one up because first I was intrigued that someone wanted to use one of my articles in their book and secondly, I got a sneak peak of a couple of the chapters and enjoyed the author’s writing style. Also, picking it up for free helped!
- Why I finished it: Because I wanted to review the book. I only read the main text though and only skimmed the rather extensive glossary / appendices.
- I’d give it to: New programmers, especially if they already had a little programming already, like a 101 class.
You can read my full review after the jump!
(more…)
Mon 25 Mar 2013
The Reportlab library is a great way to generate PDFs in Python. Recently, I noticed that it has the ability to do barcodes. I had heard about it being able to generate QR codes, but I hadn’t really dug under the covers to see what else it could do. In this tutorial, we’ll take a look at some of the barcodes that Reportlab can generate. If you don’t already have Reportlab, go to their website and get it before jumping into the article. (more…)