py3k feature proposal: field auto-assignment in constructors
Paul Rubin
http
Sun Jan 27 21:57:53 EST 2008
Wildemar Wildenburger <lasses_weil at klapptsowieso.net> writes:
> class Server(object):
> def __init__(self, self.host, self.port,
> self.protocol, self.bufsize, self.timeout):
> pass
> ?
That could temporarily bind those attributes but it shouldn't
persistently mutate the object.
How about:
class Server(object):
def __init__(self, host, port, protocol, bufsize, timeout):
self.(host, port, protocol, bufsize, timeout) = \
host, port, protocol, bufsize, timeout
That's fairly explicit yet cuts down the total amount of boilerplate.
More information about the Python-list
mailing list