파이썬에서 사용하고 싶은 API가 있습니다. 이 API에는 #define으로 구현 된 플래그 및 enum이 포함되어 있습니다.ctypes는 enum 및 플래그에 대해 어떤 것을 제공합니까?
routine(["something", "otherthing"])
stuff = getflags()
if 'something' in stuff
action('interesting')
mode = getaction()
if mode == 'interesting'
가하는 ctypes는 곧바로이 작업을 수행하는 메커니즘을 제공 하는가 :
// it's just almost C so don't bother adding the typedef and parenthesis diarrhea here.
routine(API_SOMETHING | API_OTHERTHING)
stuff = getflags()
? stuff & API_SOMETHING
action(API_INTERESTING)
mode = getaction()
? mode == INTERESTING
지금 열거 및 플래그를 제외한 다른 모든 것들을 무시하고, 내 바인딩이로 번역해야합니까? 그렇지 않다면 파이썬 바인딩에서 플래그와 enum을 다루는 '평소'도구에 대해 이야기하십시오.
이제는 '문서를 읽었으니'다른 모든 솔루션 외에도 '속성'을 사용할 수 있음을 알고 있습니다. http://docs.python.org/library/ functions.html # property –