Posts Tagged ‘fun’

Bug Fixing Attitude

Sunday, April 9th, 2006

As Mikkel “Kamstrup” noted on his blog, bug hunting is all about attitude.

Here is mine:
Bug hunting attitude

Note how the photographer interrupted the bug-fixer, forcing him to simulate a smile.

Also note the reference manual in case the man pages are missing.

What’s your bug hunting attitude ?

Fun with python

Friday, January 20th, 2006

Fun python snippets

Here is a short list of python WTF’s i often come across in my own code, debugging
those is quite hard..

Tuples are immutable ?

a = ([],[])

# Modifying a tuple ?
a[0] += [1]

print a

Weird list references:

a = [[None]*4]*3
a[0][0] = 1

print a

Import madness:

* in

* in
import mod1
def set_foo(i):
mod1.FOO = i

* in
from mod1 import *
import mod2
print FOO

Run "python"

Weird variable scoping:

* in
a = 3
def foo():
return a

if __name__ == "__main__":
for a in range(3):
print foo()

* in
from mod1 import *
a = 6
print foo()

Compare "python" and "python"

Of course these snippets are a bit convoluted, but I often find these patterns appearing randomly..

How much of them have you got right without looking at the answer before?

To Flush Or Not To Flush

Friday, December 2nd, 2005

Ok, I swear this is not me.

Moreover, I wasn’t hacking on epiphany, but reading Slashdot !