[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
instead); the buttons also wrap entry field values in parentheses to sidestep precedence issues. They could instead convert the ...
Figure 19-8. calculator_plusplus: extend, embed, and configure! This chapter concludes our Python language material in this book ...
Lesson 6: Have Fun In closing, here’s a less tangible but important aspect of Python programming. A com- mon remark among new us ...
...
CHAPTER 20 Python/C Integration “I Am Lost at C” Throughout this book, our programs have all been written in Python code. We hav ...
don’t need to be shipped with full source code and don’t require end users to learn complex or proprietary languages. In this la ...
Embedding typically takes the role of customization—by running user-configurable Python code, a system can be modified without s ...
For example, when we created buttons with Python’s tkinter GUI library earlier in the book, we called out to a C library through ...
C-coded operations with the Python interpreter as C function pointers. In all cases, the C layer is responsible for converting a ...
else { strcpy(result, "Hello, "); / build up C string / strcat(result, fromPython); / add passed Python string / return Py_Build ...
This is a Cygwin makefile that uses gcc to compile our C code on Windows; other platforms are analogous but will vary. As we lea ...
standard module and filename attributes, though the filename doesn’t end in a .py or .pyc this time around—the only obvious way ...
# to build: python disthello.py build # resulting dll shows up in build subdir from distutils.core import setup, Extension setup ...
Example 20-4. PP4E\Integrate\Extend\HelloLib\hellolib.c /***** A simple C library file, with a single function, "message", whic ...
This file spells out the C function’s type signature. In general, SWIG scans files con- taining ANSI C and C++ declarations. Its ...
C library code (in another directory) $(CLIB)/hellolib.o: $(CLIB)/hellolib.c $(CLIB)/hellolib.h gcc $(CLIB)/hellolib.c -g -I$(CL ...
imported, and we need both (scripts import the .py which in turn imports the .dll internally). As usual in C development, you ma ...
include <Python.h> include <stdlib.h> include <string.h> // / 1) module functions / // static PyObject / retu ...
// / 3) module definition / // static struct PyModuleDef cenvironmodule = { PyModuleDef_HEAD_INIT, "cenviron", / name of module ...
to add this code to Python, compile and link into an object file; the Cygwin makefile in Example 20-9 builds the C source code f ...
«
72
73
74
75
76
77
78
79
80
81
»
Free download pdf