Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Scope of import

def div(a, b):
    return a/b
from __future__ import print_function
from __future__ import division

import mydiv

print(mydiv.div(3, 2))   # 1

print(3/2)               # 1.5

The importing of functions, and the changes in the behavior of the compiler are file specific. In this case the change in the behavior of division is only visible in the division.py script, but not in the mydiv.py module.