Personal tools
You are here: Home log python module random from python2.3 to python2.2
Document Actions

module random from python2.3 to python2.2

sample() is missing in python2.2

In python2.2, random is just a monolithic python program. Whereas in python2.3, there's an additional _randommodule.c, c module and it's very hard to compile in python2.2. Even after I added following:

#ifndef PyDoc_STR
#define PyDoc_VAR(name)         static char name[]
#define PyDoc_STR(str)          (str)
#define PyDoc_STRVAR(name, str) PyDoc_VAR(name) = PyDoc_STR(str)
#endif
#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
#define PyMODINIT_FUNC void
#endif

it still got "segmentation fault" when importing.

On the other hand, sample() of python2.3 doesn't rely on the c module. So i just copied the whole sample function plus inserted "sample = _inst.sample" into the end of random.py. Now everything is fine.

« November 2009 »
Su Mo Tu We Th Fr Sa
1234567
89101112 1314
1516171819 20 21
22232425262728
2930
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: