Created
October 24, 2011 12:18
-
-
Save gipi/1308887 to your computer and use it in GitHub Desktop.
Python functions' default value is evaluated at function definition time.
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
| def bad_append(new_item, a_list=[]): | |
| """ | |
| >>> print bad_append('one') | |
| ['one'] | |
| >>> print bad_append('two') | |
| ['one', 'two'] | |
| """ | |
| a_list.append(new_item) | |
| return a_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment