Python Tutorials
A comprehensive guide that takes you from the basic to advanced concepts in the Python programming language.
Python’s null equivalent: None
What is the null or None Keyword The null keyword is commonly used in many programming languages, such as Java, C++, C# and Javascript. It is a value that is assigned to a variable. Perhaps you have seen something like this: null in Javascript [javascript] var null_variable = null; [/javascript] null in PHP [php] $null_variable […]
Read MoreMemory-Mapped (mmap) File Support in Python
What is a Memory-Mapped File in Python From Python’s official documentation, be sure to checkout Python’s mmap module: A memory-mapped file object behaves like both strings and like file objects. Unlike normal string objects, however, these are mutable. Basically, a memory-mapped (using Python’s mmap module) file object maps a normal file object into memory. This […]
Read MorePySide/PyQt Tutorial: QWebView
The QWebView is a highly useful control; it allows you to display web pages from URLs, arbitrary HTML, XML with XSLT stylesheets, web pages constructed as QWebPages, and other data whose MIME types it knows how to interpret. It uses the WebKit web browser engine. WebKit is an up-to-date, standards-compliant rendering engine used by Google’s […]
Read MoreWriting Your First Python Django Application
Create A Django Project The previous article Introduction to Python’s Django presented an overview of the Django Framework. In this article, we are going to write a simple Django application from scratch. The first step is to create a project using one of Django’s built-in commands django-admin.py. In a Virtualenv, type this command: [shell] django-admin.py […]
Read MoreLambda Function Syntax (Inline Functions) in Python
Python’s syntax is relatively convenient and easy to work with, but aside from the basic structure of the language Python is also sprinkled with small syntax structures that make certain tasks especially convenient. The lambda keyword/function construct is one of these, where the creators call it “syntactical candy”. Here we’ll examine how to use them. To understand the lambda keyword/function and their […]
Read MoreCatching Python Exceptions – The try/except/else keywords
Often times when coding a python masterpiece, there are certain things that could go wrong when executing your masterfully designed code. Things such as files or directories that are missing, empty strings, variables that are supposed to be strings but are actually arrays at run-time. These things are called exceptions in Python. This is what […]
Read MorePySide/PyQT Tutorial: QListView and QStandardItemModel
In our last instalment, we discussed Qt’s QListWidget class, which allows the user to make simple single-column list boxes. For more advanced list controls, however, a more flexible widget is required; for that reason, Qt supplies the QListView widget, which allows more varied items to be created. It is a pure presentation widget, which displays […]
Read MoreCutting and Slicing Strings in Python
Python Strings as Sequences of Characters Python strings are sequences of individual characters, and share their basic methods of access with those other Python sequences – lists and tuples. The simplest way of extracting single characters from strings (and individual members from any sequence) is to unpack them into corresponding variables. [python] >>> s = […]
Read MorePySide/PyQt Tutorial: Using Built-In Signals and Slots
In the last installment, we learned how to create and set up interactive widgets, as well as how to arrange them into simple and complex layouts using two different methods. Today, we’re going to discuss the Python/Qt way of allowing your application to respond to user-triggered events: signals and slots. When a user takes an […]
Read MorePySide/PyQt Tutorial: Interactive Widgets and Layout Containers
In the last installment, we looked at some of the functionality provided to all QWidget-descended Qt widgets, and we looked at one specific widget, the QLabel, in more depth. We also worked our way up to an example that illustrated the structure of a simple Python/Qt application. Thus far, however, we’re not able to do […]
Read More