[Python-Dev] yeah! for Jeremy and Greg

David Ascher DavidA@ActiveState.com
Tue, 28 Mar 2000 16:42:20 -0800


> I updated again and rebuilt.
> 
>     >>> def sum(*args):
>     ...     s = 0
>     ...     for x in args: s = s + x
>     ...     return s
>     ... 
>     >>> sum(2,3,4)
>     9
>     >>> sum(*[2,3,4])
>     9
>     >>> x = (2,3,4)
>     >>> sum(*x)
>     9
>     >>> def func(a, b, c):
>     ...     print a, b, c
>     ... 
>     >>> func(**{'a':2, 'b':1, 'c':6})
>     2 1 6
>     >>> func(**{'c':8, 'a':1, 'b':9})
>     1 9 8
>     >>> 
> 
> *cool*.


But most importantly, IMO:

class SubClass(Class):
	def __init__(self, a, *args, **kw):
		self.a = a
		Class.__init__(self, *args, **kw)

Much neater.