Created
April 17, 2012 05:20
-
-
Save idan/2403662 to your computer and use it in GitHub Desktop.
Parameter Usage Style
This file contains hidden or 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
# Which of these | |
def __init__(self, uri, http_method=u'GET', body={}, headers={}): | |
# do stuff with body and headers directly | |
headers['Content-Type'] = u'x-www-url-formencoded' | |
# etc... | |
# VERSUS # | |
def __init__(self, uri, http_method=u'GET', body=None, headers=None): | |
body = body or {} | |
headers = headers or {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@dcramer I don't follow. If you passed an empty structure, then a new empty one will be created which is not a big issue. The idea is not to mutate default arguments.
If you really care, you can probably use
body = {} if body is None else body
if you want to check for None explicitly.