Tag Archives: Python

Safe Directory Hopping “with” Python

Some applications need hopping around a lot between different current working directories (CWD). If you are writing such one, you might get worried that at some point control is lost and the CWD might differ from what you expected. This could certainly lead to potentially harmful consequences.

Since Python 2.5 there is a really cool feature: the with statement. There is a nice article by Fredrik Lundh [1] explaining how it works. Here I present a way to keep control over your application’s CWD making use of it.

Continue reading

interlingua

Okay, the trick is lame and—after all—rather obvious. But maybe someone still has just a little fun figuring out how this code will do.


# include <iostream>
# define nothing using namespace std; int main() { string bullshit
# define print ; cout <<
nothing = "Just another Python hacker."
# define nothing "Just another C++ hacker.\n"; return 0; }
print nothing

A Tribut to C++ Homework

For my very first homework in C++ (about half a year ago) I was asked to write a program that computes the exponential function. Up till now I was never fully satisfied by my former solution. So here is the ultimate version. A little late, but anyhow.

WeiredExponent is a program that combines a maximum of system incompatibility and user frustration potential with a minimum of calculation speed and reliability. It is a little C++ program that computes the exponential function from a number passed to it as a command line argument. However, none of the calculation steps is actually preformed by C++ code. Instead, it forks children that use Java, Fortran, Pascal and Python to carry out small pieces of work. — Each in a very inefficient way. Nevertheless, the program gets the correct results and there is no code that isn’t used. (Such like a += 0;.)

To run it, you’ll need:

WeiredExponent is of course Free Software. This means, that if you open the window and — as loud as you can — shout out: “Hello world!” then you can freely use it for any purpose you want. It is not very recommended to use WeiredExponent in important exams or as dog food. The author of this software is not responsible for bad marks, neither he is for sick dogs.

Download the C++ source code