@@ -112,6 +112,25 @@ Note that in general the practice of importing ``*`` from a module or package is
|
112 | 112 | frowned upon, since it often causes poorly readable code. However, it is okay to |
113 | 113 | use it to save typing in interactive sessions. |
114 | 114 | |
| 115 | +If the module name is followed by :keyword:`as`, then the name |
| 116 | +following :keyword:`as` is bound directly to the imported module. |
| 117 | + |
| 118 | +:: |
| 119 | + |
| 120 | + >>> import fibo as fib |
| 121 | + >>> fib.fib(500) |
| 122 | + 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 |
| 123 | + |
| 124 | +This is effectively importing the module in the same way that ``import fibo`` |
| 125 | +will do, with the only difference of it being available as ``fib``. |
| 126 | + |
| 127 | +It can also be used when utilising :keyword:`from` with similar effects:: |
| 128 | + |
| 129 | + >>> from fibo import fib as fibonacci |
| 130 | + >>> fibonacci(500) |
| 131 | + 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 |
| 132 | + |
| 133 | + |
115 | 134 | .. note:: |
116 | 135 | |
117 | 136 | For efficiency reasons, each module is only imported once per interpreter |
|