首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >python dll swig帮助

python dll swig帮助
EN

Stack Overflow用户
提问于 2010-07-17 03:51:01
回答 1查看 434关注 0票数 0

首先,我从来没有用过SWIG,我不知道它是做什么的……

我们有一个python库,据我所知使用SWIG,比如当我想要使用这个库时,我必须把这个放到我的python代码中:

代码语言:javascript
复制
import pylib

现在,如果我打开该供应商的pylib.py,我会看到一些类、函数和这个标题:

代码语言:javascript
复制
# 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相同的目录中,有一个名为_pylib.pyd的文件,我认为它是一个dll。

我的问题如下:

pylib.py中的许多类如下所示:

代码语言:javascript
复制
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)

假设我想使用这个类或它的方法,如下所示:

代码语言:javascript
复制
 *args

作为参数,我不知道我应该传递多少参数,也不知道它们应该是什么,有没有可能找到它,所以我可以使用库?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-07-17 04:09:42

SWIG是一种自动包装C/C++库的方法,因此可以从Python访问它。这个库实际上是一个编译为DLL的C库。Python代码只是传递代码,都是由SWIG自动生成的,您说得对,它没有太大帮助。

如果您想知道要传递哪些参数,就不应该查看Python代码,而应该查看生成它的C代码--如果有,则查看文档。如果你没有该库的任何代码或文档,那么我认为你将很难弄清楚它……您应该联系供应商以获取文档。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3268371

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档