two embedded problem. one maybe is python bug.
hi,all, the content of a.py : #coding:gb2312#/usr/local/bin/pythonimport randomprint random.randint(0,10) the c program: #include int main(){ Py_Initialize(); PyRun_SimpleString("import sys"); PyRun_SimpleString("sys.path.append('.')"); PyRun_SimpleString("import a"); Py_Finalize(); return 0;} the gcc cmd line: g++ -o a a.c -I/usr/local/include/python /usr/local/lib/libpython -lm -lpthread -ldl First problem: when i run the a, the error msg is : Traceback (most recent call last): File "", line 1, in ? File "./a.py", line 1SyntaxError: encoding problem: with BOM but if i first import a.py through the python cmd line. This problem disappears.(but second problem appears)(now I think the a import a.pyc not a.py) I think it's python bug, isn't it? Second problem, Traceback (most recent call last): File "", line 1, in ? File "a.py", line 3, in ? import random File "/usr/local/lib/python2.4/random.py", line 44, in ? from math import log as _log, exp as _exp, pi as _pi, e as _eImportError: /usr/local/lib/python2.4/lib-dynload/math.so: undefined symbol: PyExc_OverflowError. Pls give me some advice, i am crazy.thanks -- http://mail.python.org/mailman/listinfo/python-list
The question in source code about of funciton--PyObject_CallFunction (in file abstract.c)
hi,all. I have remarked the statement of question with blue color in the following funcition, Counld someone answer me? thanks PyObject *PyObject_CallFunction(PyObject *callable, char *format, ...){ va_list va; PyObject *args, *retval; if (callable == NULL) return null_error(); if (format && *format) { va_start(va, format); args = Py_VaBuildValue(format, va); va_end(va); } else args = PyTuple_New(0); if (args == NULL) return NULL; if (!PyTuple_Check(args)) { PyObject *a; a = PyTuple_New(1); if (a == NULL) return NULL; if (PyTuple_SetItem(a, 0, args) < 0) return NULL;//if return from here, why not release the a and args?? args = a; } retval = PyObject_Call(callable, args, NULL); Py_DECREF(args); return retval;} -- http://mail.python.org/mailman/listinfo/python-list
How to call a mothod in a class by the method name string and the instance?
hi, all: for example, the following class: class test: def funca(self): print "in funca" def funcb(self): print "in funcb" t = test() t.funca() In the plain way, i will excute the funca by the code "t.funca() ", but if i wanna to excute the funca by "t" and string "funca", how will i do? maybe the idea is similiar to "call(t, "funca") ". best regards. -- http://mail.python.org/mailman/listinfo/python-list
how to transfer a python object to other computer?
Hey, all.Now I wanna to transfer a object to other computer, Maybe I could serialize the object to a file by pickle moudle, then send the file and get it from the file.But I think the efficency is awful, because the disk io is very slow. Someone could do me a favor to give me some idea? Best Wish. -- http://mail.python.org/mailman/listinfo/python-list