100 days of code: Day 33 - from import

Last modified on 2020-07-11

Source: 100-days-of-code.

Tips on import: If using only a few classes, it’s helpful to use from module_name import Class statements to get a clear sense of the classes I am using …

from voyage import Foobar, ElectricZepplin

If using many classes, import the whole module and use the syntax module_name.ClassName

import voyage

my_voyage = voyage.ElectricZeppelin('Graf Tesla', 'Berlin', 'Tokyo')

I can use aliases for modules and classes …

from voyage import ElectricZeppelin as ez

my_voyage = ez('Graf Tesla, 'Berlin', 'Tokyo')

Happy hacking!