Thursday, June 23, 2005

Python iterators and sentinel values

The excellent blog, from __future__ import *, has an interesting article on from __future__ import * ยป Python iterators and sentinel values.

A more useful way to turn any data into a callable form.

Sunday, May 01, 2005

Small Values of Cool: Windows system tray icons with Python

Small Values of Cool: Windows system tray icons with Python provides a way to have a menu of internal links created in Python living in the system tray (I think).

ASPN : Python Cookbook : Automatically set all passed parameters to self

ASPN : Python Cookbook has a recipe for automatically assigning variables passed in to the equivalent self.variable in the class.

The simplest way is found in the comments:
Instead of specifying it as:
class Old:
def __init__(self, a, b, c, d, e, f, g, h, i=200, j=100):
self.a = a
self.b = b
self.c = c
self.d = d
... and so on

do it as:

class FooBar:
def __init__(self, a,b,c,d,e,f,g,h, i=100, j=100):
self.__dict__.update(locals())

ASPN : Python Cookbook : Readable switch construction without lambdas or dictionaries

ASPN : Python Cookbook has a recipe for an alternative switch construct in Python.

Creates a class 'switch', and then the construct is

for case in switch(variable):
if case('a'):
appropriate action
break
if case('b'):
appropriate action
...

elif can be used instead of if and eliminates need for break, but the if construct also allows pass to be the appropriate action and this allows fall-through.

Wednesday, March 02, 2005

IPython - An enhanced Interactive Python

IPython has an enhanced Interactive Python shell.

Wednesday, February 02, 2005

File Management in Python

File Management in Python is a summary of Python's capabilities for file handling.

Tuesday, January 25, 2005

Eclipse as Python IDE

Eclipse is a general purpose IDE, which with PyDev seems to give everything a Python developer might want:
# Code folding
# Refactoring with bicycle repair man.
# Code Completion
# Debugger
and more ...

Saturday, January 22, 2005

Python Idioms and Efficiency Suggestions

Python Idioms and Efficiency Suggestions is a great collection of Python hints and how to make your code better.

Monday, January 17, 2005

5 Free Windows Web Design Apps You Can't Live Without!

5 Free Windows Web Design Apps You Can't Live Without! goes from colour picker through to Firefox, but still very useful.