Использование модулей
# -*- encoding: utf-8 -*-
"""
Простейший модуль
"""
#//File: printer.py
def printer(x): # module attribute
print x
# -*- encoding: utf-8 -*-
"""
Словарь загруженных модулей
"""
import sys
print '\n'.join(sys.modules.keys())
# -*- encoding: utf-8 -*-
"""
Включение всех имен из модуля в область видимости
"""
from printer import * # copy out all variables
printer('Hello world!')
# -*- encoding: utf-8 -*-
"""
Включение имени из модуля в область видимости
"""
from printer import printer # copy out one variable
printer('Hello world!') # no need to qualify name
# -*- encoding: utf-8 -*-
"""
Импортирование модуля
"""
import printer # get module as a whole
printer.printer('Hello world!') # qualify to get names