-1
def fib(n):    # write Fibonacci series up to n
>"""Print a Fibonacci series up to n."""
>a, b = 0, 1
>while a < n:
>>print(a, end=' ')
>>a, b = b, a+b
>print()

`fib`
<function fib at 10042ed0>

The terminal returns 'function fib a 10042ed0' when fib is entered. What is 10042ed0 and where and when is it formed?

Pb3017
  • 11
  • Does this answer your question? [Symbol Table in Python](https://stackoverflow.com/questions/9085450/symbol-table-in-python) – Jacques Jul 14 '20 at 00:29
  • A function name is just a variable whose value is a function object. `10042ed0` is the internal ID of the function object. – Barmar Jul 14 '20 at 00:50
  • That's just the printed representation of a function object, the same as doing `print(object())` I'm not sure what you are asking, or what this has to do with symbol tables... Note you *never called the function object* – juanpa.arrivillaga Jul 14 '20 at 01:36

1 Answers1

0

A function definition introduces the function name 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. This value can be assigned to another name which can then also be used as a function.

Here is where i got this: http://insti.physics.sunysb.edu/itp/computing/doc/python/python-tut/section2_5_6.html

  • Thanks. That was helpful. I am still not sure what 10042ed0 is. Is that a location where the symbol table is stored? I am sure my confusion is rooted off not having clear idea of what a symbol table is. – Pb3017 Jul 14 '20 at 19:40