Python Virtual Environments Explained

What is VirtualEnv? The virtualenv tool creates an isolated Python environment (in the form of a directory) that is completely separate from the system-wide Python environment. What this really means is that any settings, 3rd-party packages, etc. from the system-wide environment do not appear in the virtual environment, so it’s almost like you have a clean Python install. This is useful for when you want to have a clean-slate for your projects. Let’s say you have boto version 2.7.0 installed […]

Read more

Pyramid Explained

What is Pyramid Pyramid is a Python web framework created from the combination of Pylons and repoze.bfg, resulting in a flexible, easy to use framework. Pyramid puts much of its focus in being flexible, so no application will be constrained by decisions made by the Pyramid creators. For example, you can use Mako or Chameleon for templating, just about any type of database for persistence, and a number of different methods for view routing (the list goes on). Many features […]

Read more

Python’s @classmethod and @staticmethod Explained

Python is a unique language in that it is fairly easy to learn, given its straight-forward syntax, yet still extremely powerful. There are a lot more features under the hood than you might realize. While I could be referring to quite a few different things with this statement, in this case I’m talking about the decorators @classmethod and @staticmethod. For many of your projects, you probably didn’t need or encounter these features, but you may find that they come in […]

Read more

Differences Between .pyc, .pyd, and .pyo Python Files

In this article we go over the Python file types .pyc, .pyo and .pyd, and how they’re used to store bytecode that will be imported by other Python programs. You might have worked with .py files writing Python code, but you want to know what these other file types do and where they come into use. To understand these, we will look at how Python transforms code you write into instructions the machine can execute directly. Bytecode and the Python […]

Read more

Python Generators

What is a Generator? A Python generator is a function that produces a sequence of results. It works by maintaining its local state, so that the function can resume again exactly where it left off when called subsequent times. Thus, you can think of a generator as something like a powerful iterator. The state of the function is maintained through the use of the keyword yield, which has the following syntax: yield [expression_list] This Python keyword works much like using […]

Read more