If you use str.format
instead of (more old-fashioned) %
formatting, you can simply do:
"http://{0[listener_port]}:{0[listener_host]}".format(self.options)
In the more general case, you can get multiple values from a dict
from a list of keys
like:
values = [d[key] for key in keys]
and unpack using *
, e.g.
"http://{0}:{1}".format(*(d[key] for key in keys))
but you can't unpack to %
formatting.