The quest for the perfect python enum/constant declaration, Part 2

Well, I’ve ended my own implementation of enum. This does not make me proud neither is something I like, particularly because it’s huge for something that I think should be more simple or part of the language. One hint for this is the many enum-like solutions you can find around the net. Some are simple and clean, but none provides all the features I need.

Anyhow, the module is pretty cool and does everything I ever wanted. From the first part:

  1. An easy way to declare a type with a set of related constants: a name and an (integer) value
  2. An easy way to convert a constant from its value to its name, and vice-versa.
  3. An easy way to declare sequence-based constants and bit-based flag constants.
  4. The type must not be immutable: new constants may be added later.

Continue reading ‘The quest for the perfect python enum/constant declaration, Part 2′

How to share a GIT repository on a web server

Objectives

  • Create a GIT repository on your computer
  • Share your repository in your own webserver, so anyone can clone it, like in:
    git clone http://foo/bar.git

In three easy steps you’ll be done, here we go…
Continue reading ‘How to share a GIT repository on a web server’

The quest for the perfect python enum/constant declaration, Part 1

Updated: python code in the following post.

As you may know, Python is such a great language: it is really well designed from the start! One example of this is that most common and useful data types are part of the main language (list, dictionaries, sets, you name it), instead of being an “add-on” or library implementation as seen in most programming languages (like collections in Java, and not to mention C and the lack of these).

However, one data type that developers always are missing is the C-equivalent enum.

Continue reading ‘The quest for the perfect python enum/constant declaration, Part 1′