Entries tagged with “Python 101”.


Over the weekend, I finished setting up a website for my upcoming book, Python 101. I discovered that www.python101.com is owned by squatters, so I got www.python101.org instead. It will redirect to http://python101.pythonlibrary.org because I think the book should be a part of Python Library while maintaining its independence.

There isn’t much content on the site yet, but I hope to be adding more as the book’s launch date approaches. For those of you who are interested, the Kickstarter Campaign has only 3 more days to go, so if you want to contribute, you’ll need to hurry!

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…)

It’s time for another update! I want to apologize for not writing sooner, but I’ve been without  internet for several days and I’m writing this from my phone. I just wanted to let you all know that I’m planning to finish part two this week.

I’ve had some people ask if I plan to release the book under a Creative Commons or similar license. While I’m not really interested in releasing the eBook itself like that, I am considering turning the book’s contents into a website, kind of like Dive Into Python.  

I may make that my next stretch goal. Let me know what you think in the comments.

If you’d like to support the book, feel free to go to the Kickstarter page

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…)

mousecovertitlejpg_sm2

My readers have been asking me to write a book for a few years now and I’ve finally decided to bite the bullet and give it a go. For my first book, I decided to write something that’s for beginners and intermediate programmers. There will be four parts to the book with the first part being aimed squarely at the beginner programmer. The next 3 parts will follow a more cookbook-like style in that they will contain a lot of tutorials. I’ll be folding some of the articles from my blog into the book and updating them if appropriate, but there will be plenty of new content.

To get things going, I am running a Kickstarter campaign. to raise some funds to help in the development of the book. If you’ve ever found this blog useful, please consider supporting the funding of my book.

I copied most of the text from the Kickstarter campaign here for your convenience: (more…)

Python’s logging module has lots of options. In this article, we will looks at the logging module’s ability to create Rotating Logs. Python supports two types of rotating logs:

  • Rotate logs based on size (RotatingFileHandler)
  • Rotate the logs based on some time interval (TimedRotatingFileHandler)

Let’s spend some time learning how each of these two types of loggers are implemented and used. (more…)

This topic is actually more complicated then it first appears. In this article, we’ll spend a little time looking at this problem and some of the solutions. (more…)

Configuration files are used by both users and programmers. They are usually used for storing your applications settings or even your operating system’s settings. Python’s core library includes a module called ConfigParser that you can use for creating and interacting with configuration files. We’ll spend a few minutes learning how it works in this article. (more…)

I wrote an article on this topic several years ago, but I think it is time for me to revisit it. Why? Well, lately I’ve been doing a lot of work on a program for sending emails and I’ve been looking at my old article and thinking I missed a few things when I first wrote it. So in this article we will learn the following:

  • The basics of emailing – kind of a rehash of the original article
  • How to send email using the TO, CC and BCC lines
  • How to send to multiple addresses at once
  • How to add an attachment and a body using the email module

Let’s get started! (more…)