Created
March 21, 2017 00:16
-
-
Save mingrammer/916732cb51f4dcd0f678ffe56bf9a339 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
headers = { | |
'Accept': 'text/plain', | |
'Content-Length': 348, | |
'Host': 'http://mingrammer.com' | |
} | |
def pre_process(**headers): | |
content_length = headers['Content-Length'] | |
print('content length: ', content_length) | |
host = headers['Host'] | |
if 'https' not in host: | |
raise ValueError('You must use SSL for http communication') | |
pre_process(**headers) | |
# content length: 348 | |
# Traceback (most recent call last): | |
# File "<stdin>", line 1, in <module> | |
# File "<stdin>", line 7, in pre_process | |
# ValueError: You must use SSL for http communication |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example is confusing and shows nothing about dict unpacking.
Shorter example like this is right usage of dict unpacking: