Sunday, July 10, 2011

window객체의 method가 생각나지 않을 때

이번은 python의 이야기가 되어버립니다만,

dir()은 글로벌 변수의 이름을 가져옵니다.
>>> dir()
['LogWriter', '__builtins__', '__doc__', '__name__', '__package__', 'dict', 'foo', 'it', 'os', 'sublime', 'sublimelog', 'sys', 'uzipimporter', 'view', 'window', 'zipimport']


type()이라는 함수는 window라는 변수이름의 타입이 무엇인지 가져옵니다.
>>> type(window)
<class 'sublime.Window'>


클래스 정의에 __dict__ 속성은 그 클래스의 멤버들을 모두 포함하고 있습니다.
>>> sublime.Window.__dict__
<dictproxy object at 0x01ABE890>
>>> print sublime.Window.__dict__
{'folders': <Boost.Python.function object at 0x015A3610>, 'get_output_panel': <Boost.Python.function object at 0x015A3540>, '__module__': 'sublime', 'show_quick_panel': <Boost.Python.function object at 0x015A37D8>, 'new_file': <Boost.Python.function object at 0x015A3C48>, 'open_file': <Boost.Python.function object at 0x015A3A48>, 'num_groups': <Boost.Python.function object at 0x015A36A0>, '__reduce__': <Boost.Python.function object at 0x014B9310>, 'active_group': <Boost.Python.function object at 0x015A3780>, 'id': <Boost.Python.function object at 0x015A3D70>, 'show_input_panel': <Boost.Python.function object at 0x015A38B8>, 'focus_view': <Boost.Python.function object at 0x015A3828>, 'active_view': <Boost.Python.function object at 0x015A3AF0>, 'focus_group': <Boost.Python.function object at 0x015A36F0>, '__doc__': None, '__init__': <built-in function __init__>, 'run_command': <Boost.Python.function object at 0x015A3910>}

#변수이름에 사용하는 것이 아니라, 클래스의 정의에 사용하는 것에 주의

No comments:

Post a Comment