[Tutor] Class instantiation parameters

Kent Johnson kent37 at tds.net
Sun Aug 7 14:40:40 CEST 2005

Jan Eden wrote:
> In Python, I would do:
> page = Show(type=type, id=id)
> class Show: def __init__(self, type, id): self.id = id self.type =
> type ... return self
> For two parameters, this is relatively simple. But if I have for
> example 10 parameters on instantiation, assigning each value the the
> class object manually will be really clumsy.
> So how can I add the values of all the paramaters to my class
> instance in one step?

There was recently a long discussion of this on comp.lang.python.

A simple solution is
    def __init__ (self, x, y, z):
        del self.self


More information about the Tutor mailing list