Idea about method parameters

Wolfgang Grafen wolfgang.grafen at marconi.com
Mon Sep 24 19:29:11 CEST 2001


Don't think you cannot do it already!

>>> class Autoinit:
...     def __init__(self,**a):
...         self.__dict__.update(a)
...
>>> a=Autoinit(a=1,b=2,c=3)
>>> a.a
1
>>> a.b
2
>>> a.c
3

>>> class A(Autoinit):
...   def __call__(self):
...     print self.a,self.b,self.c
... 
>>> a=A(a=1,b=2,c=3)
>>> a()
1 2 3

Cheers

Wolfgang



More information about the Python-list mailing list