Skip to content

Instantly share code, notes, and snippets.

@clarksun
Created December 12, 2017 01:44
Show Gist options
  • Save clarksun/c226adebbd8e07c47c3f118947a87c0e to your computer and use it in GitHub Desktop.
Save clarksun/c226adebbd8e07c47c3f118947a87c0e to your computer and use it in GitHub Desktop.
关键字参数使用 #python
# kafka/consumer/group.py
class KafkaConsumer(six.Iterator):
DEFAULT_CONFIG = {
'bootstrap_servers': 'localhost',
'xxx':'yyy',
}
def __init__(self, *topics, **configs):
self.config = copy.copy(self.DEFAULT_CONFIG)
for key in self.config:
if key in configs:
self.config[key] = configs.pop(key)
# Only check for extra config keys in top-level class
assert not configs, 'Unrecognized configs: %s' % configs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment