2010-07-16 71 views
0

首先,我從來沒有使用痛飲,我不知道它做什麼...蟒蛇DLL痛飲幫助

我們有一個Python庫,是據我可以告訴使用痛飲,說,當我想用這個庫我必須把這個在我的Python代碼:

import pylib 

現在,如果我去開這個軟件供應商pylib.py我看到一些類,函數和這個頭:

# This file was automatically generated by SWIG (http://www.swig.org). 
# Version 1.3.33 
# 
# Don't modify this file, modify the SWIG interface instead. 
# This file is compatible with both classic and new-style classes. 

import _pylib 
import new 
new_instancemethod = new.instancemethod 

接下來,在與pylib.py相同的目錄,有af ile叫_pylib.pyd,我認爲是一個dll。

我的問題是這樣的:

class PersistentCache(_object): 
    __swig_setmethods__ = {} 
    __setattr__ = lambda self, name, value: _swig_setattr(self, PersistentCache, name, value) 
    __swig_getmethods__ = {} 
    __getattr__ = lambda self, name: _swig_getattr(self, PersistentCache, name) 
    __repr__ = _swig_repr 
    def __init__(self, *args): 
     this = _pylib.new_PersistentCache(*args) 
     try: self.this.append(this) 
     except: self.this = this 
    __swig_destroy__ = _pylib.delete_PersistentCache 
    __del__ = lambda self : None; 
    def setProperty(*args): return _pylib.PersistentCache_setProperty(*args) 
    def getProperty(*args): return _pylib.PersistentCache_getProperty(*args) 
    def clear(*args): return _pylib.PersistentCache_clear(*args) 
    def entries(*args): return _pylib.PersistentCache_entries(*args) 
PersistentCache_swigregister = _pylib.PersistentCache_swigregister 
PersistentCache_swigregister(PersistentCache) 

說我想使用這個類或它的方法,用的東西,如::

*args 
在pylib.py這個樣子的

許多類

作爲參數,我不知道我應該通過多少參數,他們應該是什麼,我有什麼可以找到這個,所以我可以使用庫?

回答

2

SWIG是一種自動包裝C/C++庫的方法,因此可以從Python訪問它。該庫實際上是一個編譯爲DLL的C庫。 Python代碼只是傳遞代碼,所有代碼都是由SWIG自動生成的,你說的沒錯。

如果你想知道通過什麼參數,你不應該看看Python代碼,你應該看看它生成的C代碼 - 如果你有它,或者如果不是,那麼文檔。如果您沒有該庫的任何代碼或文檔,那麼我認爲您將有一個非常困難的時間計算出來......您應該聯繫供應商以獲取文檔。