2010
03.03

These last three weeks have been really stressful for me due to various reasons. Anyway, I managed to get some spare time to do something funny, like the self-replicating script posted in the previous entry.

Sometimes, when we’re working on a problem, we need to denote a variable with an uknown value. C and SQL uses NULL for this purpose, while Lisp uses nil and Python have None. Let’s look python closer: sometimes, None really means none. But there are some cases we need another semantic interpretation. For example, I like to work with the unknown value, which means something different to none (None) which I use for different a purpose. We can do this:

This works because in python, Classes are also objects. The is operator only returns True if two objects are the same instance. Even better, the is operator allows an interesting syntax when used with not:

This not only enhances (IMHO) code legibility, it also make comments useless: the code is the comment itself.

Finally, this idea can be also used to define your own Infinitum value:

Share