Naming Convention aka PHP vs Python

The naming convention. It’s obviously better to have any than none. As I was writing, I noticed that the title doesn’t reflect what I wrote. All turned out to be not about convention, but about comparing PHP to Python. Personally none of the languages is my favorite.

After reading the whole post, I realized that Python is not better than PHP, it is messed the same way, so why bother changing from PHP to Python?

Indentation Checking in Ruby

In Python blocks have to be indented just because the indentation level defines the logic. In C/C++/Java there are { and } while in Ruby there is begin and end. Of course indenting is helpful. Just like syntax coloring in editor.

In Ruby you can do whatever you want with the indentation. That’s not a problem. Every good editor can fix the code layout due to some rules. Normally I use VIM for all those scripting languages, for programming in Ruby and Python too. In VIM after opening any file I can do the magic command:

Oh, Those Terrible Units

There are some numbers and units. Numbers are numbers. Units are units. Numbers informs how many. Units inform about two things:

  • how many
  • of what

Unfortunately it seems like most programmers just don’t care about all that stuff.

Virtualenv Tutorial

Here is a newer version of this virtualenv tutorial.

What Virtualenv Is

Virtualenv is a great piece of software. It allows to create virtual environments. Each of them can have a different version of Python and different sets of libraries.

While creating this tutorial I used following tools and versions:

  • virtualenv - 1.4.8
  • Python - 2.6.5
  • Ubuntu 10.04 64 bit
  • All console programs run with UTF-8

Do I Need a Virtual Environment?

As usually: it depends. Normally you can create and use Python programs without that, but using virtual environments can help a lot.

Such a virtual environment provides many possibilities such as:

  • On production servers it allows to run applications created for different Python versions.
  • On testing servers it allows to perform many tests including:
    • Testing the installer script if that really installs all necessary libraries with checking their versions.
    • Testing applications using different set of libraries.
    • Checking if upgrade of a library won’t cause errors.

Testing Database - Small Reply

I found this on the Ovid’s blog.

First of all: this is quite a nice writing of something called the modern perl. Everybody who shouts that perl is a piece of shit should read it. YES, you can write a nice looking code in perl. Code that is maintainable, and is easy to read. And is objective (a kind of somewhat different langauge syntax but who cares. Each language is different and has different class definitions - consider Ada, Perl, C++ and Python).

Some ideas about the testing solution. Of course this is PostgreSQL :).