Created
December 14, 2011 05:29
-
-
Save dketov/1475397 to your computer and use it in GitHub Desktop.
Использование модулей
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Импортирование модуля | |
""" | |
import printer # get module as a whole | |
printer.printer('Hello world!') # qualify to get names |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Включение имени из модуля в область видимости | |
""" | |
from printer import printer # copy out one variable | |
printer('Hello world!') # no need to qualify name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Включение всех имен из модуля в область видимости | |
""" | |
from printer import * # copy out all variables | |
printer('Hello world!') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Словарь загруженных модулей | |
""" | |
import sys | |
print '\n'.join(sys.modules.keys()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
""" | |
Простейший модуль | |
""" | |
#//File: printer.py | |
def printer(x): # module attribute | |
print x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment