Python3> Functions> Function Renaming Mechanism> f = fib

Python 3.5.2 documents

http://docs.python.jp/3/tutorial/controlflow.html#defining-functions

When you define a function, the function name is included in the current symbol table. The value of the function name has a type that is recognized by the interpreter as a user-defined function. You can assign this value to another name and later use that name as a function. This acts as a general renaming mechanism:

>>> fib
<function fib at 10042ed0>
>>> f = fib
>>> f(100)
0 1 1 2 3 5 8 13 21 34 55 89

fib is defined as f and used. Is it something like an alias? I don't think this was the case with the languages I've experienced so far.

It seems that you can use def to make the function name easy to understand, and to shorten it for a little processing.

Recommended Posts

Python3> Functions> Function Renaming Mechanism> f = fib
python function ①
[Python] function
Python functions
python function ②
python enumerate function
Python> function> Closure
[Python] Generator function
#Python basics (functions)
[Beginner] Python functions
Python> function> Inner function
Python Easy-to-use functions
Python function decorator
Python basics: functions
[Python for Hikari-] Chapter 06-01 Functions (Intrinsic Functions and Function Definitions)
Python Beginner's Guide (Functions)
Python basic course (12 functions)
About function arguments (python)
Function execution time (Python)
[Python] Memo about functions
Python function argument summary
Python print function (sequel)
Python: About function arguments
Time floor function (Python)
# 4 [python] Basics of functions
Python built-in functions ~ Zip ~
Wrap Python built-in functions
[python] Manage functions in a dictionary (command table, function table, function pointer)