Created
September 28, 2011 15:23
-
-
Save fredrick/1248219 to your computer and use it in GitHub Desktop.
Optional function arguments in Python
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
def hello(f, k=None): | |
""" | |
@param f is required | |
@param k is optional | |
""" | |
if (k == None): return '%s, hello world!' % f | |
else: return 'Hello %s!, said %s' % (f, k) | |
print(hello('Tony')) | |
print(hello('Tony', 'Fred')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment