2007年07月03日 星期二 09:24
Çë½Ìһϣ¬ÓÃcдÁËÒ»¸ö¼òµ¥µÄhellomodule.cÎļþ£¬ÈçÏ£º
#include "Python.h"
static PyObject *sayhello(PyObject *self)
{
return Py_BuildValue("s","Hello Python World!");
}
static PyMethodDef hellomethods[]=
{
{
"say",sayhello,METH_VARARGS
},
{
NULL,NULL
}
};
DL_EXPORT(void) inithello()
{
Py_InitModule("hello",hellomethods);
}
ÈçºÎ±àÒëÔËÐÐÄØ£¿
лл
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070702/1436473b/attachment-0001.html
2007年07月02日 星期一 19:01
没看内容的正确性, 不过一般来说要编译只需要
#gcc -o /py_lib_path/so_name.so -shared -fPIC -lpython2.x
your_c_cxx_source.c 就可以鸟 ...
pyh 写道:
> 请教一下,用c写了一个简单的hellomodule.c文件,如下:
> #include "Python.h"
> static PyObject *sayhello(PyObject *self)
> {
> return Py_BuildValue("s","Hello Python World!");
> }
> static PyMethodDef hellomethods[]=
> {
> {
> "say",sayhello,METH_VARARGS
> },
> {
> NULL,NULL
> }
> };
> DL_EXPORT(void) inithello()
> {
> Py_InitModule("hello",hellomethods);
> }
> 如何编译运行呢?
> 谢谢
> ------------------------------------------------------------------------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
2007年07月03日 星期二 09:38
编译成一个动态库,放到Python搜索路径,就可以import了。
pyh wrote:
> 请教一下,用c写了一个简单的hellomodule.c文件,如下:
> #include "Python.h"
> static PyObject *sayhello(PyObject *self)
> {
> return Py_BuildValue("s","Hello Python World!");
> }
> static PyMethodDef hellomethods[]=
> {
> {
> "say",sayhello,METH_VARARGS
> },
> {
> NULL,NULL
> }
> };
> DL_EXPORT(void) inithello()
> {
> Py_InitModule("hello",hellomethods);
> }
> 如何编译运行呢?
> 谢谢
> ------------------------------------------------------------------------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
2007年07月03日 星期二 11:28
admin.foo.com 去 replace www.foo.com/admin/ 开始准备用 web server rewrite 但是好像不行 _________________________________________________________________ 享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com
2007年07月03日 星期二 11:55
On 7/3/07, cun heise <cunheise在hotmail.com> wrote: > admin.foo.com 去 replace www.foo.com/admin/ > 开始准备用 web server rewrite > 但是好像不行 > settings.py吧,不是admin_settings.py。它是一个配置文件。 -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
2007年07月03日 星期二 12:06
ÄǸö×öadmin.foo.comµÄÈË£¬¸æËßÎÒÒªÕâÑù×ö£¬
ÇëÎÊÊÇ·ñÓÐÆäËü·½·¨£¬ÔÚÍøÕ¾ÕÒÁ˰ëÌì˵ÊÇdjango {{ app_path }}µÄbug
ÎÒÏëËûµÄÒâ˼¿ÉÄÜÊÇÏàͬµÄproject²»Í¨µÄsettings Îļþ°É¡£
>From: limodou <limodou在gmail.com>
>Reply-To: python-chinese在lists.python.cn
>To: python-chinese在lists.python.cn
>Subject: Re: [python-chinese]ÓÐÈËÖªµÀ admin-settings.py Âð£¬ÎÒÔõôÕÒ²»µ½Õâ
¿éµÄdocument
>Date: Tue, 3 Jul 2007 11:55:22 +0800
>
>On 7/3/07, cun heise <cunheise在hotmail.com> wrote:
> > admin.foo.com å?replace www.foo.com/admin/
> > 开始准备用 web server rewrite
> > 但是好像不行
> >
>settings.pyå§ï¼ä¸æ¯admin_settings.pyã宿¯ä¸ä¸ªé
ç½®æä»¶ã?>
>--
>I like python!
>UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
>My Blog: http://www.donews.net/limodou
>_______________________________________________
>python-chinese
>Post: send python-chinese在lists.python.cn
>Subscribe: send subscribe to python-chinese-request在lists.python.cn
>Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
>Detail Info: http://python.cn/mailman/listinfo/python-chinese
_________________________________________________________________
ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà Live Messenger;
http://get.live.com/messenger/overview
2007年07月03日 星期二 17:48
win 上的话,编译成 dll, link 的时候加上 python2.x 的lib, 然后吧 dll 放
到库搜索路径里。
pyh 写道:
> 请教一下,用c写了一个简单的hellomodule.c文件,如下:
> #include "Python.h"
>
>>> static PyObject *sayhello(PyObject *self)
>>> {
>>> return Py_BuildValue("s","Hello Python World!");
>>> }
>>> static PyMethodDef hellomethods[]=
>>> {
>>> {
>>> "say",sayhello,METH_VARARGS
>>> },
>>> {
>>> NULL,NULL
>>> }
>>> };
>>> DL_EXPORT(void) inithello()
>>> {
>>> Py_InitModule("hello",hellomethods);
>>> }
>>> 如何编译运行呢?
>>> 谢谢
>>>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
2007年07月03日 星期二 18:18
dllµÄ»°»áÌáʾÕÒ²»µ½£¬Ó¦¸Ã°ÑÀ©Õ¹Ãû¸Ä³É.pyd°É On 7/3/07, huanghao.c <huanghao.c在gmail.com> wrote: > > win Éϵϰ£¬±àÒë³É dll, link µÄʱºò¼ÓÉÏ python2.x µÄlib£¬ È»ºó°É dll ·Å > µ½¿âËÑË÷·¾¶Àï¡£ > > pyh дµÀ: > > Çë½Ìһϣ¬ÓÃcдÁËÒ»¸ö¼òµ¥µÄhellomodule.cÎļþ£¬ÈçÏ£º > > #include "Python.h" > > > >>> static PyObject *sayhello(PyObject *self) > >>> { > >>> return Py_BuildValue("s","Hello Python World!"); > >>> } > >>> static PyMethodDef hellomethods[]= > >>> { > >>> { > >>> "say",sayhello,METH_VARARGS > >>> }, > >>> { > >>> NULL,NULL > >>> } > >>> }; > >>> DL_EXPORT(void) inithello() > >>> { > >>> Py_InitModule("hello",hellomethods); > >>> } > >>> ÈçºÎ±àÒëÔËÐÐÄØ£¿ > >>> лл > >>> > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070703/10394803/attachment.htm
2007年07月03日 星期二 23:21
今天在刚装的SLES10上学python 没有另外装python,就用系统自带的python2.4 在目录/usr/lib/python2.4/下 我看了一下path >>> import sys;sys.path ['', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2 .4/site-packages', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python24.zip', '/usr/lib/python2.4/lib-dynload'] 安装TurboGears就很麻烦 我还要 --install -dir /usr/lib/python2.4/ 好容易装上了 现在总是报这个错 ImportError: No module named pkg_resources 是我环境变量的问题么 在ubuntu上没这些问题啊
2007年07月04日 星期三 07:43
请教一下,用c写了一个简单的hellomodule.c文件,如下:
#include "Python.h"
>> static PyObject *sayhello(PyObject *self)
>> {
>> return Py_BuildValue("s","Hello Python World!");
>> }
>> static PyMethodDef hellomethods[]=
>> {
>> {
>> "say",sayhello,METH_VARARGS
>> },
>> {
>> NULL,NULL
>> }
>> };
>> DL_EXPORT(void) inithello()
>> {
>> Py_InitModule("hello",hellomethods);
>> }
>> 如何编译运行呢?
>> 谢谢
2007年07月04日 星期三 09:02
On 7/3/07, 王超 <wch在cic.tsinghua.edu.cn> wrote: > 今天在刚装的SLES10上学python > 没有另外装python,就用系统自带的python2.4 > 在目录/usr/lib/python2.4/下 > 我看了一下path > >>> import sys;sys.path > ['', '/usr/lib/python2.4', > '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2 > .4/site-packages', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python24.zip', > '/usr/lib/python2.4/lib-dynload'] > 安装TurboGears就很麻烦 我还要 > --install -dir /usr/lib/python2.4/ > 好容易装上了 > 现在总是报这个错 > ImportError: No module named pkg_resources > 是我环境变量的问题么 在ubuntu上没这些问题啊 pkg_resources是setuptools中的一个功能,是不是你没有安装啊,它是第三方模块,需要单独安装的。 -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
Zeuux © 2025
京ICP备05028076号