assign class variable in __init__

Peter Otten __peter__ at web.de
Tue Jun 8 14:09:24 EDT 2010


Jean-Michel Pichavant wrote:

> def __init__(self, source="test", length=1):
> self.source = source
> self.length = length
> 
> is the way to go. OP's original idea is a bad idea :).

D'accord.

> Could be a problem with hundreds of parameters, but who write
> constructors with hundreds of parameters ?





More information about the Python-list mailing list