Created
January 8, 2017 12:24
-
-
Save zeraf29/9d9486435860256af2f943369ef65c32 to your computer and use it in GitHub Desktop.
Python namespace function example
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
#파이썬 네임스페이스 접근 함수 | |
#locals() 로컬 네임스페이스 내용 딕셔너리 반환 | |
#globals() 글로벌 네임스페이스 내용 딕셔너리 반환 | |
animal = 'fruitbat' | |
def change_local(): | |
animal = 'wombat' # local variable | |
print('locals:',locals()) | |
print('globals:',globals()) | |
print(animal) | |
change_local() | |
print('globals:',globals()) | |
print(animal) | |
#전역 위치에서 locals 호출 | |
print('locals:',locals()) | |
#globals()와 동일 효과 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python namespace example2(namespace call function)