[issue22202] Function Bug?

Steven D'Aprano report at bugs.python.org
Fri Aug 15 02:29:59 CEST 2014


Steven D'Aprano added the comment:

Thank you for the extensive examples, but I'm afraid this is not a bug.

In your code, "result" is a local variable, which means it only exists inside the fib() function. When you try inspecting "result", it fails because there is no global variable "result".

Try doing this instead:

result = fib(100)
result
result[3]


and it should work as you expect. (By the way, it doesn't matter if the local variable inside the fib() function and the global variable are different names or the same, in both cases they are considered different.)

----------
nosy: +steven.daprano
resolution:  -> not a bug

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22202>
_______________________________________


More information about the Python-bugs-list mailing list