Cross-Platform


When you’re first starting out as a Python programmer, you don’t think about how you might need to install an external package or module. But when that need appears, you’ll want to know how to in a hurry! Python packages can be found all over the internet. Most of the popular ones can be found on the Python Package Index (PyPI). You will also find a lot of Python packages on github, bitbucket, and Google code. In this article, we will be covering the following methods of installing Python packages:

  • Install from source
  • easy_install
  • pip
  • Other ways to install packages

(more…)

The lxml.objectify sub-package is extremely handy for parsing and creating XML. In this article, we will show how to create XML using the lxml package. We’ll start with some simple XML and then try to replicate it. Let’s get started! (more…)

Code profiling is an attempt to find bottlenecks in your code. Profiling is supposed to find what parts of your code take the longest. Once you know that, then you can look at those pieces of your code and try to find ways to optimize it. Python comes with three profilers built in: cProfile, profile and hotshot. According to the Python documentation, hotshot “no longer maintained and may be dropped in a future version of Python”. The profile module is a pure Python module, but adds a lot of overhead to profiled programs. Thus we will be focusing on cProfile, which has an interface that mimics the profile module. (more…)

kivy_poster_1

Kivy is an open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. The Kivy organization is organizing its second application development contest.! This is a great chance for new and experienced users to show off their skills and compete for prizes. Entries will be judged on a range of criteria accessible to both new and experienced programmers, so don’t be afraid to dive in! For more information, visit http://kivy.org/#contest

The wxPython Google Group was discussing different methods of catching exceptions in wxPython the other day. If you use wxPython a lot, you will soon realize that some exceptions are difficult to catch. The wxPython Wiki explains why. Anyway, the fellows on the list were recommending the use of sys.excepthook. So I took one of the methods they mentioned and created a little example: (more…)

Reportlab is a very flexible PDF creation package for Python. You can layout your documents using absolute positioning or by using Flowable objects, such as a Paragraph, a Table or Frame. You can even mix the two together! In this article, we will be looking at how to create some custom Flowables. For example, what do you do if you need to add a line to demarcate the start of a new section in your document? There isn’t really a built-in Flowable for that, so we’ll design our own. We will also design a flowable that has a line and a box with text inside of it.

Let’s get started! (more…)

There’s a Python book contest going on over on the Bite Sized Python Tips blog. You can get one of 3 copies of the book Tkinter GUI Application Development by Bhaskar Chaudhary. I reviewed this book late last year and found it be a really interesting book. I think it will give you lots of good ideas to try in developing your own GUI applications. Now’s your chance to get a copy of this neat book!

I had a lot of ideas for the cover of Python 101. My first idea was to go to the zoo and take some photographs of Pythons there, then pick the right one stick that on the cover. I have a lot of photo editing software, so I also considered taking the photo and changing it so it looked like a drawing or a painting. Then I started thinking about my blog and how my readers were the ones encouraging me to write the book in the first place. So I ended up going with one of my other ideas, which was to continue the Mouse Vs Python theme.

I ended up hiring an artist I know who did my original blog logos. His name is Tyler and he owns and operates Killustration Studios. You can see some of his work on deviantArt. Anyway, I told him my ideas for the book cover and I thought I would share the various versions of the cover as it evolved.

The First Rough Cover

The following image is the first version of the cover. It’s pretty rough, but I could see my vision taking shape:

python101rough01072014_0000_sm

(more…)

Python has a vast library of modules that are included with its distribution. The csv module gives the Python programmer the ability to parse CSV (Comma Separated Values) files. A CSV file is a human readable text file where each line has a number of fields, separated by commas or some other delimiter. You can think of each line as a row and each field as a column. The CSV format has no standard, but they are similar enough that the csv module will be able to read the vast majority of CSV files. You can also write CSV files using the csv module. (more…)

Python has a number of different concurrency constructs such as threading, queues and multiprocessing. The threading module used to be the primary way of accomplishing concurrency. A few years ago, the multiprocessing module was added to the Python suite of standard libraries. This article will be focused on the threading module though. (more…)

Next Page »