AliasingΒΆ
Functions are objects in Python. You can assign them for example to variables.
[23]:
# shortcut
rp = repeat_print
[24]:
rp()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-24-b1f065dd3a83> in <module>
----> 1 rp()
TypeError: repeat_print() missing 1 required positional argument: 's'
Or you can put them into containers.
[25]:
my_functions = {
"f": our_first_function,
"one": function_one,
"rp": repeat_print,
}
[26]:
my_functions["one"]()
[26]:
1