@@ -29,16 +29,16 @@ called :file:`fibo.py` in the current directory with the following contents::
2929
3030 def fib(n): # write Fibonacci series up to n
3131 a, b = 0, 1
32- while b < n:
33- print(b , end=' ')
32+ while a < n:
33+ print(a , end=' ')
3434 a, b = b, a+b
3535 print()
3636
3737 def fib2(n): # return Fibonacci series up to n
3838 result = []
3939 a, b = 0, 1
40- while b < n:
41- result.append(b )
40+ while a < n:
41+ result.append(a )
4242 a, b = b, a+b
4343 return result
4444
@@ -52,17 +52,17 @@ the current symbol table; it only enters the module name ``fibo`` there. Using
5252the module name you can access the functions::
5353
5454 >>> fibo.fib(1000)
55- 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
55+ 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
5656 >>> fibo.fib2(100)
57- [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
57+ [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
5858 >>> fibo.__name__
5959 'fibo'
6060
6161If you intend to use a function often you can assign it to a local name::
6262
6363 >>> fib = fibo.fib
6464 >>> fib(500)
65- 1 1 2 3 5 8 13 21 34 55 89 144 233 377
65+ 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
6666
6767
6868.. _tut-moremodules :
@@ -92,7 +92,7 @@ module directly into the importing module's symbol table. For example::
9292
9393 >>> from fibo import fib, fib2
9494 >>> fib(500)
95- 1 1 2 3 5 8 13 21 34 55 89 144 233 377
95+ 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
9696
9797This does not introduce the module name from which the imports are taken in the
9898local symbol table (so in the example, ``fibo `` is not defined).
@@ -101,7 +101,7 @@ There is even a variant to import all names that a module defines::
101101
102102 >>> from fibo import *
103103 >>> fib(500)
104- 1 1 2 3 5 8 13 21 34 55 89 144 233 377
104+ 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377
105105
106106This imports all names except those beginning with an underscore (``_ ``).
107107In most cases Python programmers do not use this facility since it introduces
@@ -145,7 +145,7 @@ executed as the "main" file:
145145.. code-block :: shell-session
146146
147147 $ python fibo.py 50
148- 1 1 2 3 5 8 13 21 34
148+ 0 1 1 2 3 5 8 13 21 34
149149
150150 If the module is imported, the code is not run::
151151
0 commit comments