unknown's Articles
Introduction to Python Classes (Part 2 of 2)
In the first part of this series, we looked at the basics of using classes in Python. Now we’ll take a look at some more advanced topics. Python Class Inheritance Python classes support inheritance, which lets us take a class definition and extend it. Let’s create a new class that inherits (or derives) from the […]
Read MorePySlices with Tkinter
Among the numerous libraries and software suites Python developers have created with and for Python is the Py Suite, a group of tools written in wxPython to assist Python enthusiasts with their programming endeavors. Included in this suite is a Python shell worthy of mention called PySlices. Perhaps this shell’s most distinguishing feature is the capability […]
Read MoreUsing the Python Tempfile Module
While programming in Python, there will likely be times where you have some data that needs to be utilized or manipulated in the form of a file but hasn’t yet been written to one. Naturally, the first solution that comes to mind is to open a new or existing file, write the data and finally […]
Read MoreIntroduction to Python Classes (Part 1 of 2)
Classes are a way of grouping related bits of information together into a single unit (also known as an object), along with functions that can be called to manipulate that object (also known as methods). For example, if you want to track information about a person, you might want to record their name, address and […]
Read MoreIntroduction to Python on AWS with Boto
Amazon Web Services offer us all cheap, ready access to serious cloud computing infrastructure. So how do we run Python on it? Setting up Python on Amazon EC2 EC2 is Amazon’s Elastic Compute Cloud. It’s the service used to create and operate virtual machines on AWS. You can interact with these machines using SSH, but […]
Read MoreReal-World Regular Expressions for Python
We’ve covered a lot of ground in this series of articles, so let’s now put it all together and work through a real-life application. A common task is to parse a Windows INI file, which are key/value pairs, separated into sections, something like this: [python] [Section 1] val1=hello world val2=42 [Section 2] val1=foo! [/python] Let’s […]
Read MoreThe Odds & Ends of Python Regular Expressions
In the first two parts of this series, we looked at some fairly advanced usage of regular expressions. In this part, we take a step back and look at some of the other functions Python offers in the re module, then we talk about some common mistakes people regularly (ha!) make. Useful Python Regular Expression […]
Read MoreMore About Python Regular Expressions
In the first part of this series, we looked at the basic syntax of regular expressions and some simple examples. In this part, we’ll take a look at some more advanced syntax and a few of the other features Python has to offer. Regular Expression Captured Groups So far, we’ve searched within a string using […]
Read MoreIntroduction to Python Regular Expressions
Searching within a string for another string is pretty easy in Python: [python] >>> str = ‘Hello, world’ >>> print(str.find(‘wor’)) 7 [/python] This is fine if we know exactly what we’re looking for, but what if we’re looking for something not so well-defined? For example, if we want to search for a year, then we […]
Read MoreFun With Python Function Parameters
Virtually every programming language has functions and procedures, a way of separating out a block of code that can be called many times from different places in your program, and a way to pass parameters into them. Python is no different, so we’ll quickly run over the standard stuff that most languages have, then take […]
Read More