Suppose I have a python fibo.py model defined below:
In my interpreter session, I do the following:
>> import fibo This is a statement >>> fibo.fib(10) 1 1 2 3 5 8 >>> fibo.fib2(10) [1, 1, 2, 3, 5, 8] >>> fibo.__name__ 'fibo' >>>
So far so good .. drag the translator:
>>> from fibo import fib,fib2 This is a statement >>> fibo.__name__ Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'fibo' is not defined >>>
I was expecting an error as I only imported fib and fib2. But I donโt understand why the expression was printed when I imported only fib and fib2.
Secondly, if I change the module as:
#Fibonacci numbers module print "This is a statement" print __name__
What should be the expected result?
source share