Education


Python decorators are really cool, but they can be a little hard to understand at first. A decorator in Python is a function that accepts another function as an argument. The decorator will usually modify or enhance the function it accepted and return the modified function. This means that when you call a decorated function, you will get a function that may be a little different that may have additional features compared with the base definition. But let’s back up a bit. We should probably review the basic building block of a decorator, namely, the function. (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…)

I’m sure some of you have been wondering if I had a more concrete outline of the book that I am currently writing. As a matter of fact, I do. Here’s what I have so far:

Part One: Learning the Basics

  • Chapter 1 – IDLE
  • Chapter 2 – Strings
  • Chapter 3 – Lists, Tuples and Dictionaries
  • Chapter 4 – if/elif/else statements
  • Chapter 5 – Loops
  • Chapter 6 – Comprehensions
  • Chapter 7 – Exception handling
  • Chapter 8 – Working with Files
  • Chapter 9 – Importing
  • Chapter 10 – Functions
  • Chapter 11 – Classes

Note: Part One is written and in the editing phase

(more…)

Editor’s note: This is a guest post from Yasoob Khalid who authors the Free Python Tips blog

So hi there guys! I hope you are fine. So what is in this post? Today we will be writing a cleanup script. The idea for this post came from Mike Driscoll who recently wrote a very useful post about writing a cleanup script in python. So how is my post different from his post? (more…)

The Real Python: Advanced Web Development, featuring Django 1.6 KickStarter campaign released a preview chapter today called “Software Craftmanship”. It is the first chapter from the book. The PDF download consists of 33 pages.

You can go get it too by going to the following address: http://www.realpython.com/preview/. If you haven’t already, you can still support their Kickstarter for 3 more days.

I recently received a copy of Kivy: Interactive Applications in Python by Roberto Ulloa. This is currently the only book about Kivy. Kivy is a cross-platform GUI toolkit that will run on Linux, Windows, and OS X as well as Android and iOS. In fact, the people behind Kivy emphasize that this is aimed primarily at mobile programming. Kivy supports multitouch and has a very active group of programmers. You can read more about Kivy on their project’s home page. I will be reviewing the PDF version of the book.

Here’s my quick review for those of you without a lot of time:

Quick Review

  • Why I picked it up: I received this book as payment for helping with the reviewing of another Packt book, but I would have bought it myself because I am interested in learning Python for Android/iOS and I like learning about Python GUI toolkits.
  • Why I finished it: The book is short and I was optimistic that it would get better.
  • I’d give it to: Someone who already knows Python and the basics of Kivy, although I don’t think I would recommend it.

(more…)

python_machine_learning

Earlier this year, Packt Publishing asked me to be a technical reviewer of one of their upcoming books, “Building Machine Learning Systems with Python” by Willi Richert and Luis Pedro Coelho. Now the book is available for purchase and they have asked me to write a little about it. I haven’t read through the finished product myself, so I don’t know if the authors followed any of my advice, but I should note that English appeared to be their second language, so the book will likely be a little rough.

However, the content is interesting and I thought it was fairly comprehensive. They appeared to know what they were talking about. A lot of this book is over my head as I am not a scientist or engineer in the topic that this book covers. Basically, this book is about data mining using scikit-learn, mahotas and jug. You will learn about such heady topics as computer vision, basket analysis, how to classify data, etc.

You can check the book out on Packt’s website or on Amazon.

UPDATE (2013-08-22) – One of the authors commented on this post to let me know that they’ve cleaned up the text.

My wife teaches 3rd grade math and she recently learned about the process of obtaining the digital root of numbers. The digital root is a single digit number found by summing the individual digits. So for 15, you would add 1+5 to get 6. Thus 6 is the digital root of 15. The trainer that my wife worked with explained that you can check your answers using the digital root, which will give children another way to find out if their answer is correct. Here is an example:

15   1 + 5 = 6
+12   1 + 2 = 3
      6 + 3 = 9
----
 27   2 + 7 = 9

So here we have two operands: 15 and 12. If you add those together, you get 27. To check your answer using the digital root, you add the individual digits in the two operands as above. So 15 becomes 1+5 or 6 and 12 becomes 1+2 or 3. Then you add those two roots together to get 9. Then you check your answer by adding up its digits, which in this case is 2+7 which equals 9. The rules are slightly different for subtraction, multiplication and division. We’ll be looking at addition, subtraction and multiplication. We are skipping division because I haven’t found a good explanation for how it works and I don’t want to just use formulas that I can’t explain.

At this point you’re probably wonder where Python comes in. We’ll use wxPython to create a simple GUI that will allow us to see how this works. Let’s start coding! (more…)

I first heard about Blaze from NumPy’s original developer’s blog back in December 2012. A few days ago, InformationWeek announced that DARPA was funding the project to the tune of $3 million dollars to get some big data libraries written for Python. There will be two new projects, Blaze and Bokeh. Blaze will be an extension of NumPy and SciPy and make those libraries big data friendly. The Bokeh project will be for big data visualization.

Blaze will be open source. You can read more about it here. I was unable to find a specific link to the Bokeh project.

Python provides a very powerful logging library in its standard library. A lot of programmers use print statements for debugging (myself included), but you can also use logging to do this. It’s actually cleaner to use logging as you won’t have to go through all your code to remove the print statements. In this tutorial we’ll cover the following topics:

  • Creating a simple logger
  • How to log from multiple modules
  • Log formatting
  • Log configuration

By the end of this tutorial, you should be able to confidently create your own logs for your applications. Let’s get started! (more…)

Next Page »