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).
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.