Python Tutorials
A comprehensive guide that takes you from the basic to advanced concepts in the Python programming language.
Using Python’s Tabnanny Module for Cleaner Code
Tabnanny is a module in Python that checks your source code for ambiguous indentation. This module is useful because in Python, white space isn’t supposed to be ambiguous, and if your source code contains any weird combinations of tabs and spaces, tabnanny will let you know. You can run tabnanny in one of two ways, […]
Read MorePython Resources: Training Videos
Sometimes the best way to get acquainted with a new language or a new technique is to watch someone else do it first, and then jump in to try for yourself. If you like to learn that way and are wanting to improve your Python skills, check out any of the training videos or video […]
Read MoreThe Difference Between __str__ and __repr__
__str__ and __repr__ are used in very similar ways in Python, but they’re not interchangeable. __str__ is a built in function used to compute the informal string representations of an object, while __repr__ must be used to compute the official string representations of an object. The visible difference between the informal and official representations has […]
Read MorePython Comparison Operators
In Python, comparison operators are used to compare the values on either side of the operators and then decide the relationship between them (sometimes they’re also referred to as relational operators). What follows is a complete list of the comparison operators in Python. Some of them might be pretty self-explanatory, while others you may have […]
Read MorePython’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 More