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.
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.
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 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 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.
File Management in Python is a summary of Python's capabilities for file handling.
Python Idioms and Efficiency Suggestions is a great collection of Python hints and how to make your code better.
5 Free Windows Web Design Apps You Can't Live Without! goes from colour picker through to Firefox, but still very useful.