Skip to content

Instantly share code, notes, and snippets.

@zeraf29
Created January 8, 2017 12:24
Show Gist options
  • Save zeraf29/9d9486435860256af2f943369ef65c32 to your computer and use it in GitHub Desktop.
Save zeraf29/9d9486435860256af2f943369ef65c32 to your computer and use it in GitHub Desktop.
Python namespace function example
#파이썬 네임스페이스 접근 함수
#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()와 동일 효과
@zeraf29
Copy link
Author

zeraf29 commented Jan 8, 2017

python namespace example2(namespace call function)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment