idiom for constructor?

Peter Dembinski pdemb at gazeta.pl
Sat Jun 4 06:05:31 EDT 2005


Peter Dembinski <pdemb at gazeta.pl> writes:

[snap]

Eh, sorry, it should look like this:

> #v+
>
> class A:
>     def __init__(self, a, b, c, d):
>         initial = {'a' : 1, 'b' : 2, 'c' : 3, 'd' : 4}          
          initial = {'a' : a, 'b' : b, 'c' : c, 'd' : d}
>
>         for param in initial.keys():
>             exec "self.%s = initial['%s']" % (param, param)
>
> #v-



More information about the Python-list mailing list