If it won't be simple, it simply won't be. [Hire me, source code] by Miki Tebeka, CEO, 353Solutions

Thursday, May 17, 2007

Websession

A nice class for supporting sessions in CGI scripts.
Usage Example:

Monday, May 07, 2007

Avoiding Indent

To reduce the amount of indentation, you can negate your logic:

def positive_logic(x):
if x > 2:
y = f(x)
if y < 10:
g = f(y)
if g > 0:
do_cool_stuff(g)

will become:

def negative_logic(x):
if x <= 2:
return
y = f(x)
if y >= 10:
return
g = f(y)
if g <= 0:
return
do_cool_stuff(g)

Blog Archive