How to Time Small Pieces of Python Code with timeit

Sometimes when you are coding, you want to know how long it takes for a particular function to run. This topic is known as profiling or performance tuning. Python has a couple of profilers built into its Standard Library, but for small pieces of code, it’s easier to just use Python’s timeit module. Thus, timeit […]

How to Time Small Pieces of Python Code with timeit Read More »

Python 101: Writing a cleanup script

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

Python 101: Writing a cleanup script Read More »

wxPython: An Introduction to Sized Controls

The wxPython toolkit provides an alternative to using Sizers for layout that is known as “sized_controls”. These controls or widgets are basically top-level widgets (like frame, panel, dialog, etc) that have sizing logic built into them. This article will cover all four types of sized_controls. They are as follows: SizedPanel SizedScrolledPanel SizedFrame SizedDialog The SizedScrolledPanel

wxPython: An Introduction to Sized Controls Read More »

wxPython: Wrap Widgets with WrapSizer

wxPython 2.9 introduced the world to a new type of sizer that can take widgets and automatically make them “wrap” around as you resize the frame. That sizer is known as wx.WrapSizer. For some reason, it is relatively unknown, so we’ll spend a few minutes going over how to use it in this article. To

wxPython: Wrap Widgets with WrapSizer Read More »

How to Create “Immutable” Classes in Python

I’ve been reading a lot about Python’s magic methods lately and recently read about a couple of ways to create an immutable class. An immutable class does not allow the programmer to add attributes to an instance (i.e. monkey patch). It’s a little easier to understand if we actually look at a normal class first.

How to Create “Immutable” Classes in Python Read More »

Real Python: Advanced Web Development Preview Chapter

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

Real Python: Advanced Web Development Preview Chapter Read More »

Top Ten Articles of 2013

Happy New Year! It’s the end of 2013 and the beginning of 2014, so it’s time to see which articles made it into the top ten list this year. I ran the statistics on December 31st and came up with the following list: Python: A Simple Step-by-Step SQLite Tutorial (37,658 page views) Python 101: How

Top Ten Articles of 2013 Read More »