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

Import module containing class

You probably want your classes to be reusabel by multiple programs, so it is better to put the class and your code using it in separate files right from the beginning. In this example you can see how to do that importing the module and then using the dot notation to get to the class.

import shapes

p = shapes.Point()
print(p)          # <shapes.Point instance at 0x7fb58c31ccb0>
class Point:
    pass