Facundo Batista <[EMAIL PROTECTED]> wrote: > Josiah Carlson wrote: > > sentinel = object() > > > > def connect(HOST, PORT, timeout=sentinel): > > ... > > if timeout is not sentinel: > > sock.settimeout(timeout) > > ... > > > > A keyword argument via **kwargs is also fine. I have no preference. > > I do. The way you showed here, I'm not restricting user options. I think > this is better.
But the kwargs doesn't restrict options either... def connect(address, **kwargs): ... if 'timeout' in kwargs: sock.settimeout(kwargs['timeout']) ... With that method you can include timeout=None, and it also doesn't restrict what the user could pass as a value to timeout. It requires that you pass timeout explicitly, but that's a (relatively inconsequential) API decision. - Josiah _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com