python
RecobaLee
这个作者很懒,什么都没留下…
展开
-
python中的多线程(2)
我们在上一章中看到使用threading.Thread.join()可以避免主程序在等待其它线程结束的过程中得到时间片。事实上,在线程编程中经常会遇到一个线程需要等待另一个线程中的情况。在这种情况下,需要重申的是,我们不希望等待的线程获得时间片。 解决的办法是使用条件变量,就像它的名称,代码使用它们来等待一些条件的成立。大多数线程系统都支持条件变量,python的threading...2007-07-15 20:15:00 · 189 阅读 · 0 评论 -
关于wxpython中wx.lib.customtreectrl.GenericTreeItem的问题
在使用wx.lib.customtreectrl的过程中,如果在它的构造函数中指定了TR_AUTO_CHECK_CHILD属性,那么在生成的树中如果选择的树选项有子选项的话,那么这些子选项也会被选中。这本来是一个很实用的功能,但是使用以后发现有一个问题,就是子选项被选中但是并不触发相应的EVT_TREE_ITEM_CHECKED事件,使得在程序中需要自己手动去罗列所有的子选项。 ...2007-07-23 21:30:52 · 737 阅读 · 0 评论 -
Extending and Embedding the Python Interpreter(一)
Let's create an extension module called "spam" (the favorite food of Monty Python fans...) and let's say we want to create a Python interface to the C library function system().This function takes a n...2007-08-27 13:12:50 · 222 阅读 · 0 评论 -
Extending and Embedding the Python Interpreter(二)
An important convention throughout the Python interpreter is the following: when a function fails, it should set an exception condition and return an error value (usually a NULL pointer). Exceptions a...2007-08-28 13:17:23 · 203 阅读 · 0 评论 -
Extending and Embedding the Python Interpreter(三)
Going back to our example function, you should now be able to understand this statement: if (!PyArg_ParseTuple(args, "s", &command)) return NULL;It returns NULL (the error indic...2007-08-29 12:42:32 · 149 阅读 · 0 评论 -
Extending and Embedding the Python Interpreter(四)
I promised to show how spam_system() is called from Python programs. First, we need to list its name and address in a ``method table'': static PyMethodDef SpamMethods[] = { ... {"system", ...2007-09-02 20:31:31 · 183 阅读 · 0 评论 -
Extending and Embedding the Python Interpreter(五)
There are two more things to do before you can use your new extension: compiling and linking it with the Python system. If you use dynamic loading, the details may depend on the style of dynamic loadi...2007-09-02 20:41:32 · 187 阅读 · 0 评论 -
关于python中的除法
首先要说的是python中的除法运算,在python 2.5版本中存在两种除法运算,即所谓的true除法和floor除法。当使用x/y形式进行除法运算时,如果x和y都是整形,那么运算的会对结果进行截取,取运算的整数部分,比如2/3的运算结果是0;如果x和y中有一个是浮点数,那么会进行所谓的true除法,比如2.0/3的结果是0.66666666666666663。另外一种除法是采用x//y的...2008-02-25 22:02:51 · 295 阅读 · 0 评论 -
关于python中的浮点数
由于计算机表示方法的问题,计算机中整数和浮点数的二进制表示是不同的。我们知道,如果要把一个10进制整数转化为相应的2进制数只要把10进制数不断的除2取余就可以了。而浮点数的小数部分是不一定能够用2进制来准确表示的,要将一个小数转化为相应的2进制数需要将小数部分不断的乘2,并截取相应的整数部分。比0.625转为二进制:0.625*2 = 1.25, 整数部分为1,小数部分为0.250.25...2008-02-25 22:26:42 · 866 阅读 · 0 评论