Uncategorized
Activate Admin Application for Your Python Django Website
In the previous article , we learned how to write two models Post and Comment for your Django application myblog. In this article, we are going to learn how to activate Django’s automatic admin site that provides a convenient interface for users or administrators of your website myblog to create, read, update and delete (CRUD) […]
Read MoreWriting Models for Your First Python Django Application
The previous article Writing Your First Python Django Application is a step-by-step guide on how to write a simple Django application from scratch. In this article, you will learn how to write models for your new Django application. Software Architectural Patterns Before we dive into the code, let’s review two of the most popular server-side […]
Read MoreRecursive File and Directory Manipulation in Python (Part 2)
In Part 1 we looked at how to use the os.path.walk and os.walk methods to find and list files of a certain extension under a directory tree. The former function is only present in the Python 2.x, and the latter is available in both Python 2.x and Python 3.x. As we saw in the previous […]
Read MoreIntroduction to Python’s Django
What is Web Development Web development is a broad term for any work that involves creating a web site for the Internet or an intranet. The end product of a web development project varies from simple sites composed of static web pages to complex applications that interact with databases and users. The list of tasks […]
Read MorePySide/PyQt Tutorial: The QListWidget
Qt has a couple of widgets that allow single-column list selector controls — for brevity and convenience, we’ll call them list boxes. The most flexible way is to use a QListView, which provides a UI view on a highly-flexible list model which must be defined by the programmer; a simpler way is to use a […]
Read MorePySide/PyQt Tutorial: Creating Your Own Signals and Slots
You don’t have to rely solely on the signals that are provided by Qt widgets, however; you can create your own. Signals are created using the Signal class. A simple signal definition would be: Then, when the conditions for the object being tapped are satisfied, you call the signal’s emit method, and the signal is […]
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 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 MorePython Unicode: Encode and Decode Strings (in Python 2.x)
Strings are among the most commonly used data types in Python, and there might be times when you want to (or have to) work with strings containing or entirely made up of characters outside of the standard ASCII set (e.g. characters with accents or other markings). Python 2.x provides a data type called a Unicode […]
Read More