summaryrefslogtreecommitdiff
path: root/learning_python/mutable_params.py
diff options
context:
space:
mode:
Diffstat (limited to 'learning_python/mutable_params.py')
-rw-r--r--learning_python/mutable_params.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/learning_python/mutable_params.py b/learning_python/mutable_params.py
new file mode 100644
index 0000000..6e2fdce
--- /dev/null
+++ b/learning_python/mutable_params.py
@@ -0,0 +1,13 @@
+
+def append_to(element, to=[]):
+ to.append(element)
+ return to
+
+
+if __name__ == '__main__':
+
+ my_list = append_to(12)
+ print(my_list, append_to)
+
+ my_other_list = append_to(42)
+ print(my_other_list, append_to)