Install Python Pip

Often, the best way to install the latest version of python application is through the Python package management system (pip). The following script will install and upgrade pip on your ubuntu system. sudo apt-get install python-pip python-dev build-essential sudo pip install --upgrade pip…

Read this article

Python Modules

Modules are just files that can contain any number of classes, functions and variables. The name of the module is exactly the same as the name of the file, excluding the extension (.py). Unlike other languages, in Python one does not necessarily define one file per class, and thus the…

Read this article

Python - Importing

There are three main ways to import modules in Python with subtle but important differences that we will cover below: import [module name] from [module name] import [class/variable/function name] from [module name] import * In our earlier tutorial where we created a basic Employee class. In this tutorial we…

Read this article

Python Classes

Below is an example of a basic class used in a Python script class Employee: 'Common base class for all employees' __s_empCounter = 0 # static variable for incrementing IDs # Private member variables __id = None __name = None __salary = None def __init__(self, name, salary): self.__name = name self.__salary = salary Employee.…

Read this article

Python Notifier

You've probably noticed pop-up dialogues appearing when you have new mail in Thunderbird, or Dropbox has been updated etc. Every modern Linux desktop distribution appears to have these. It's really easy to create these notifications in Python. You can even add icons to them, although this is rarely used. The…

Read this article

Python and JSON

The main things to know when working with JSON are: import with import json json.dumps(arg) will return a JSON string based on arg json.dumps will accept: lists tuples dictionaries json.dumps will not accept sets ranges json.loads(stringArg) can be used to convert a JSON string…

Read this article

Python Data Types

Sequences Sequences are all indexed by numbers. There are six sequence types: Strings Byte sequences (bytes objects) bytearray lists tuples range List A specific type of sequence (collection indexed by a number). Muteable (can be edited after creation) Elements can be of different types. Example construction emptyList = [] emptyList2 = list() listOfDifferentTypes…

Read this article

Netbeans - Add Python Support

Netbeans is my IDE of choice as a PHP, Java, and C++ developer on Linux (but it also works on windows). Unfortunately there is no download option for supporting python. Also, you will not find "python" plugins when searching for installable plugins from the plugin manager. This tutorial will show…

Read this article

Python Multithreading - You Could Be Wasting Time

Python is an excellent scripting language that seems especially suitable for Linux applications. You may have heard that python has multithreading support, which is true, and could dramatically improve your application's performance as demonstrated by running the following two examples below, which are trying to simulate connecting to 4 different…

Read this article