1
print가 내장 파이썬 함수인지 여부를 프로그래밍 방식으로 확인하고 싶습니다. .py를 파일에서 사용할 때파이썬 내장 함수가 일관성이 없음
['ArithmeticError', 'AssertionError', ..... , 'pow', 'print' ... ]
:하지만 파이썬 3.4.x를 사용
는파이썬 명령 줄에서 dir(__builtins__)
를 쿼리 내가 무엇을 찾고 얻을 때
import sys
def foo:
print(dir(__builtins__))
호출은 다음을 반환합니다.
['__class__', '__contains__', '__delattr__', '__delitem__', '__dir__',
'__doc__', '__eq__', '__format__', '__ge__', '__getattribute__',
'__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__',
'__len__', '__lt__', '__ne__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__setitem__',
'__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy',
'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault',
'update', 'values']
__builtins__
을 다시 정의하지 않았습니다. y 점.
작품 :
오히려
__builtins__
보면보다는builtins
모듈을 사용! 훌륭한 설명에 감사드립니다. – Willeman