From what I’ve seen of Python, I relegated it to CUI and backend type tasks, since C# and .NET offer a powerful GUI platform out of the box, and Python seemingly didn’t have anything similar.
After looking into the OpenERP/OpenObject project (which looks pretty neat), I realized their complex GUI was written in Python. After a little investigation, I figured out they were using PyGTK (Python bindings for the GTK widget toolkit) and Glade (a GUI builder).
Combining Python, PyGTK and Glade seems to lead to a workable solution for creating GUIs for Python applications. There’s a nice tutorial on how all these pieces fit together here.
I’ve used many different programming languages, each with their own set of benefits and flaws. C++ was the first one I learned, and every class that I’ve taken has used it (with the exception of two language classes).
Before we discuss the pros and cons of C++, here’s a factoid: C++ is based on C, which was written in 1972 (approximately 37 years ago) at Bell Labs for use with the UNIX operating system.
Read more…
September 6th, 2009
recon
If you have several old PCs lying around, you could turn them into a grid, a single computer that uses all their resources together.
I haven’t found a good use for a grid personally, but I found a nice piece software to setup a SSI (Single System Image, basically means one OS running on multiple machines) grid, and a nice tutorial.
If I had a grid running MySQL, the 35 million row DB table I use would probably search pretty fast.
In other news, Panda3D (a game engine, usable from C++ or Python) looks like it has excellent documentation, something that a lot of engines are lacking. I’m also wondering if I should buy a Mac now that Snow Leopard is out (that’s when I said I’d buy one)… I wonder if I’d really use the Mac applications…
OOP is different in each programming language. Some languages like Python and C# don’t offer all the OOP features that you can get from C++.
Python doesn’t really support traditional access modifiers, and C# doesn’t offer true multiple inheritance (you can inherit from one class and multiple interfaces).
While C++ offers the most OOP features of the three languages, it has some disadvantages. If you compare C++ to modern languages like Python, Ruby or C#, C++ starts to show it’s age. Further more, given a small application, it’s usually much faster to write it in Python than in any C language.
The question ultimately becomes, are all the OOP features in C++ really needed in every day development? For small projects, most likely, no. For large projects with a team of developers, maybe.
Python methods (functions that are part of a class) have a special explicit parameter called self. Through self, methods can access class members (without a self parameter, the method is static (no access to instance variables)).
In most C languages, the “self” parameter is hidden (an implicit parameter), and is usually accessible through a reserved word (e.g this is C++ and C#).
Which is better? Python’s upfront approach is nice for beginners, but for experienced programmers, it creates some extra work.
Classes started today, pretty exhausted…
I’m planning a new project, pygcp, which will be a GCP for people who have a dedicated box, and want to manage their servers from a web interface.
At this point, I’m planning to write pygcp for people who install their own servers, but want to use something to manage the task of running them (it would replace something like ServerChecker) from a web interface.
I might add auto installs and a master/slave system, but that’s a long way off.
Compiling mysql-python shouldn’t have been too complicated, since distutils automates the compilation process, but there were two minor issues.
This particular module needed the /MANIFEST linker option, and the windows setup script didn’t work properly.
After fixing both of those problems, I present the compiled binaries (MySQL-python-1.2.3c1.win32-py2.6.exe (83)), and the fixed setup_windows.py (mysql-python-setup_windows.py (79)), if you want to compile mysql-python yourself.
Loops are another “flow control” tool, like an if statement. Loops allow you to repeat the same piece of code multiple times, which can be very useful when you are processing data.
There are two types of loops in Python, the for loop, and the while loop. The for loop is one of the easiest ways to process data. Let’s take a look:
Read more…
I’ll be posting my Python code here. If you have questions, leave a comment the code’s download page.
I just finished a little backup script, which copies files only if they are newer than the copy in the destination folder, or if they don’t exist in the destination yet.
Continuing from tutorial 4, we’ll discuss object oriented programming, classes, and how OO is applied in Python.
First of all, if we’re not doing object oriented programming, what kind of programming are we doing? Most likely, procedural. Procedural programming uses multiple functions to accomplish a task. Object oriented programming is the idea of packaging related variables and functions together in a reusable container called a class. Technically, OO is about modeling real world objects.
Read more…