Beispiel #1
0
% python mod1.py
2 3
1 2 3



### file: changer.py

message = "First version"
def printer():
    print(message)



>>> import changer
>>> changer.printer()
First version



### file: changer.py (edited and saved)

message = "After editing"
def printer():
    print('reloaded:', message)



>>> import changer
>>> changer.printer()                 # No effect: uses loaded module
First version
Beispiel #2
0
# import Map

# Map.add('图层名','index')
# print(Map.allLayers)
# print(list(dir(Map.__dict__.keys())))
# print(Map.__name__)

import changer
changer.printer()

Beispiel #3
0
# 모듈 리로드하기

message = "First version"


def printer():
    print(message)


# python
import changer
changer.printer()
# First version

message = "After editing"


def printer():
    print('reloaded:', message)


import changer
changer.printer()  # 아무 효과가 없음: 이미 적재된 모듈 사용
# First version
from imp import reload
reload(changer)  # 새로운 코드를 적재하해릿 공하도록 강제
# <module 'changer' from '.\\changer.py'>
changer.printer()  # 이제 새로운 버전이 동작함
# reloaded: After editing