Monthly Archives: June 2014

Packt Publishing is having a Sale on Python books this week

Packt Publishing recently asked me if I would be interested in letting my readers know about a sale that they are doing right now. Most of the time, I avoid marketing to my readers, but Packt has a lot of Python ebooks for sale this week that I think you might find useful. Here is their press release (plus links to my reviews of the book, if applicable):


Packt Publishing celebrates 10 years with a special $10 offer


It has been 10 years since Packt Publishing embarked on its mission to deliver effective learning and information services to IT professionals. In that time, it has published over 2000 titles and helped projects become household names, awarding over $400,000 through its Open Source Project Royalty Scheme.

To celebrate this huge milestone, Packt is offering all of its eBooks and Videos at just $10 each – this promotion covers every title and customers can stock up on as many copies as they like until July 5th If you’ve already tried a Packt title in the past, you’ll know this is a great opportunity to explore what’s new and maintain your personal and professional development. If you’re new to Packt, then now is the time to try their extensive range – Within their 2000+ titles range, you’ll find the knowledge you really need , whether that’s specific learning on an emerging technology or the key skills to keep you ahead of the competition in more established tech fields.’

Some of the Python books that you can check out:

• Kivy Interactive Applications in Python (review)

• Tkinter GUI Application Development HOTSHOT (review)

• Instant Flask Web Development (review)

• web2py Application Development Cookbook (review)

• Numpy 1.5 Beginner’s Guide (review)

• MySQL for Python (review)

• Python Multimedia Application Beginner’s Guide (review)

• Python 3 Object Oriented Programming (review)

More information is available at:

My First Interview

Last week, DZone contacted me to ask if I would like to be featured in their “Dev of the Week” series. In other words, they wanted to do a short interview with me. The interview went live yesterday. You can read it here, if you like:

I don’t know why the link is on their java sub-domain, but needless to say, I talked about Python in almost all of my answers. I wouldn’t be posting a link to my interview on my blog if it didn’t have something to do with Python. Anyway, if you’d like to learn a little more about me, I thought you might find that interesting.

PyDev and Python profiler UI Crowdfunding Project

Last year there was an Indiegogo crowdfunding campaign in support of PyDev, the Python IDE plugin for Eclipse. It was put on by the primary developer of PyDev, Fabio Zadrozny. As a part of that campaign, Fabio also created LiClipse.

Anyway, Fabio is at it again with a new crowdfunding campaign. You can read about it here. Fabio has two targets for this campaign. The first is adding the following features to PyDev:

  • Allow preferences which are currently global to be configured per-project.
  • Provide a proper way to export/import PyDev settings to a new workspace.
  • Suport for namespace packages in code-completion.
  • Provide a way to auto-document types as well as checking existing types in docstrings when doing a test run.
  • Allow running an external pep8 linter (to support newer versions of
  • Show vertical lines for indentation.
  • Attach debugger to running process (although some caveats apply and under certain circumnstances this may not be possible).
  • Other requests to be defined based on community input as funding allows.

The second is, in my opinion, a bit more interesting. Fabio is planning on writing a profiler for PyDev that can also work outside of PyDev using Python and Qt. He has a list of features for the profiler listed in his campaign. It sounds pretty interesting. It should also be noted that PyDev and the proposed profiler will be open source, so you can always check out how the code works behind the scenes.

If you think either of these items sound interesting, then you should consider supporting Fabio in his endeavors.

Book Contest: Win a Copy of Python 101

This contest is now over

I have decided to sponsor a contest for my first book, Python 101. I will be giving away 3 copies of my eBook bundle (PDF, EPUB and MOBI) and 1 copy of the paperback, which I will ship anywhere in the world. If you haven’t heard of my book, you may want to read this other post.

How You Can Win

To win your copy of this book, all you need to do is come up with a comment below highlighting the reason “why you would like to win this book”.

Duration of the contest & selection of winners

The contest is valid for 2 weeks, and is open to everyone. Winners will be selected on the basis of their comment posted. The contest will close on 07/04/2014 at 9 a.m. CST.


PyRun – Running Python with a Single File

eGenix announced this week that they were releasing an “open source, one file, no installation version of Python”. You can read their entire announcement in their press release here. If you want to check out the actual product, you can get it at the following URL:

This is a Unix-based Python and they state that they only provide Linux, FreeBSD and Mac OS X, as 32- and 64-bit versions, so if you’re a Windows guy, you’re out of luck. I think one of the coolest aspects of this tool is that it’s 11MB for Python 2 and 13MB for Python 3, but it still supports most Python applications and code that you’ve written. If you write a lot of code that depends on 3rd party utilities, than I don’t think PyRun will be very helpful to you. But if you depend mostly on Python’s standard library, than I can see this as a very handy tool.

An alternative to PyRun would be Portable Python which provides a large number of 3rd party libraries that are baked in with the standard library. I’ve used Portable Python in several applications of my own where I didn’t want to install Python itself. Anyway, I hope you find this information useful in your own endeavors.

Python: Create Fake Data with Faker

Every once in a while, I run into a situation where I need dummy data to test my code against. If you need to do tests on a new database or table, you will run into the need for dummy data often. I recently came across an interesting package called Faker. Faker’s sole purpose is to create semi-random fake data. Faker can create fake names, addresses, browser user agents, domains, paragraphs and much more. We will spend a few moments in this article demonstrating some of Faker’s capabilities. Continue reading Python: Create Fake Data with Faker

Working Around Shadowed Functions

Recently I ran into an issue where an application that calls Python would insert int into Python’s namespace, which overwrites Python’s built-in int function. Since I have to use the tool and I needed to use Python’s int function, I needed a way around this annoyance.

Fortunately, this is fairly easy to fix. All you need to do is import int from __builtin__ and rename it so you don’t overwrite the inserted version:

from __builtin__ import int as py_int

This gives you access to Python’s int function again, although it is now called py_int. You can name it whatever you like as long as you don’t name it int.

The most common circumstance where one shadows builtins or other variables is when the developer imports everything from a package or module:

from something import *

When you do an import like the one above, you don’t always know what all you have imported and you may end up writing your own variable or function that shadows one that you’ve imported. That is the main reason that importing everything from a package or module is so strongly discouraged.

Anyway, I hope you found this little tip helpful. In Python 3, the core developers added a builtins module basically for this very purpose.

Python 101 Book Published Today!

My first book, Python 101 has been published today. You can buy it directly from my blog which will get you a PDF, EPUB and MOBI version of the book. You can also purchase a softcover edition of the book via Lulu. Finally, I have published the eBook to Amazon.

If you happen to run a Python or technology blog and would be interested in reviewing my book, Python 101, please feel free to contact me with your blog’s information. I am looking for a few good bloggers to review the book.


Order Now

Here’s some more information about the book:

Part One

The first part is the beginner section. In it you will learn all the basics of Python. From Python types (strings, lists, dictionaries) to conditional statements to loops. You will also learn about comprehensions, functions and classes and everything in between! Note: This section has been completed and is in the editing phase.

Part Two

This section will be a curated tour of the Python Standard Library. The intent isn’t to cover everything in it, but instead it is to show the reader that you can do a lot with Python right out of the box. We’ll be covering the modules I find the most useful in day-to-day programming tasks, such as os, sys, logging, threads, and more.

Part Three

This section covers mostly intermediate level material. Here are the topics covered:

  • lambda
  • decorators
  • properties
  • debugging
  • testing
  • profiling

Part Four

Now things get really interesting! In part three, we will be learning how to install 3rd party libraries (i.e. packages) from the Python Package Index and other locations. We will cover easy_install and pip. This section will also be a series of tutorials where you will learn how to use the packages you download. For example, you will learn how to download a file, parse XML, use an Object Relational Mapper to work with a database, etc.

Part Five

The last section of the book will cover how to share your code with your friends and the world! You will learn how to package it up and share it on the Python Package Index (i.e. how to create an egg or wheel). You will also learn how to create executables using py2exe, bb_freeze, cx_freeze and PyInstaller. Finally you will learn how to create an installer using Inno Setup.

Writing Style

This book will be written using my original blogging style. This means that the chapters will be shorter than your usual programming textbook. Most chapters will most likely be less than 10 pages! The idea here is to get the reader up to speed on the subject, not to beat them over the head with it.
Who should read this book?

This book is for beginners, but I believe people with intermediate skills will also find its contents valuable.