Embed Python scripting in C applications
|
|
|
- Ralf Austin Reed
- 10 years ago
- Views:
Transcription
1 Embed Python scripting in C applications ibm.com/developerworks Table of contents If you're viewing this document online, you can click any of the topics below to link directly to that section. 1. Before you start Introduction to how Python embedding works The fundamentals of embedding Build embedded applications Advanced embedding techniques Working with Python classes Summary and resources Embed Python scripting in C applications Page 1 of 24
2 ibm.com/developerworks Section 1. Before you start About this tutorial Embedding a scripting language into your applications offers many benefits, such as the ability to use functionality from an embedded language that would otherwise be a difficult or at least a lengthy process from within C. Typical examples of such functionality include the regular expression and text-handling functionality that languages such as Python use for parsing documents and other information. Other examples include adding scripting ability to your applications (often used by game programmers to build the components of a game, from characters to objects) or providing a user-extensible component to the language, much like the macro systems in many desktop applications. This tutorial shows you how to embed Python scripts in your C applications and explains how you can use the functionality of the Python scripting language from within C to extend the capabilities of the host language. We first look at the basics -- that is, the conversion of information between the two languages -- and then at the different methods for embedding Python scripts into your C applications. You should have a basic knowledge of Python programming and some experience in compiling C programs. Prerequisites The examples in this tutorial rely on your having access to a recent version of Python (Python 2.1 or later). You can download Python from the Python home page ( at Python.org. You also need access to a C compiler and a suitable make tool, such as make, gmake, or dmake. Both the compiler and the tool should be standard with most UNIX/Linux installations. About the author Martin C. Brown is a former IT Director with experience in cross-platform integration. A keen developer, he has produced dynamic sites for blue-chip customers, including HP and Oracle, and is the Technical Director of Foodware.net. Now a freelance writer and consultant, MC (as he is better known) works closely with Microsoft as an SME, is the LAMP Technologies Editor for LinuxWorld magazine, is a core member of the AnswerSquad.com team, and has written several books on topics as diverse as Microsoft certification, imacs, and open source programming. Despite his best attempts, he remains a regular and voracious programmer on many platforms and numerous environments. For technical questions or comments about the contents of this tutorial, contact MC at [email protected] or through his Web site ( or Page 2 of 24 Embed Python scripting in C applications
3 ibm.com/developerworks click Feedback at the top of any panel. Embed Python scripting in C applications Page 3 of 24
4 ibm.com/developerworks Section 2. Introduction to how Python embedding works Why use embedding? The problem with most compiled languages is that the resulting application is fixed and inflexible. Long before Python was developed, I worked with free-text databases in which I would parse and reformat a dump of the data and de-dupe keyword lists and reformat addresses and other information. At the time, C was all I had available. Developing a cleaner application was a long and complicated process -- not because the data were particularly complex, but because each time the database changed, I had to add new functions to handle different types of information and to parse the data in new ways to cope with the new fields. Today, I'd probably use Python embedded in a C application to perform these same tasks. The C application would rarely change; it would take in information from the Python component and reprocess the data for the desired output format. The Python component would parse the source text, and I'd be able to handle any type of database format I needed just by rewriting the Python component embedded in the C application. I could do all this without recompiling the C application, yet I'd still have all the speed of a native C application. In short, by embedding the Python interpreter into my application, I can combine the best of both worlds and use the best components of each language and environment to my advantage. In this case, it's the text-parsing capability, but you could just as easily use the same methods to support all sorts of applications that could benefit from the combination of the two languages. Principles of Python embedding You can execute Python code from within a C application in three ways: by using an arbitrary Python string, by calling a Python object, or by integrating with a Python module. The Python string is just a piece of text that you might otherwise have executed from within Python by using the exec statement of the eval function. Beyond the different execution methods, the basic sequence is straightforward: 1. Initialize an instance of the Python interpreter. 2. Execute your Python code (string, object, or module). 3. Close (finalize) the Python interpreter. The actual embedding process is easy, but getting the process and integration between the different areas correct is more difficult. This process is the main focus of this tutorial. There are different ways in which you can integrate between the different components Page 4 of 24 Embed Python scripting in C applications
5 ibm.com/developerworks to allow for more effective communication. Let's start by looking at the embedding API and how to translate between C and Python datatypes. Embed Python scripting in C applications Page 5 of 24
6 ibm.com/developerworks Section 3. The fundamentals of embedding The Python Embedding API The Python Embedding API is surprisingly simple. The functions are a combination of those that execute code, such as PyRun_String, those that control the environment for the code, such as PyImport_ImportModule, or those that supply and/or access information and objects from the environment. Table 1 summarizes the main functions. C API call Python equivalent Description PyImport_ImportModule import module Imports a module into the Python insta PyImport_ReloadModule reload(module) Reloads the specified module PyImport_GetModuleDict sys.modules Returns a dictionary object containing t of loaded modules PyModule_GetDict module. dict Returns the dictionary for a given objec PyDict_GetItemString dict[key] Gets the value for a corresponding dict key PyDict_SetItemString dict[key] = value Sets a dictionary key s value PyDict_New dict = {} Creates a new dictionary object PyObject_GetAttrString getattr(obj, attr) PyObject_SetAttrString setattr(obj, attr, val) Gets the attribute for a given object Sets the value for a given attribute in a object PyEval_CallObject apply(function, args) Calls a function with arguments in arg PyRunString eval(expr), exec expr Executes expr as a Python statement PyRun_File execfile(filename) Executes the file filename PySetProgramName sys.argv[0] = name Changes the name of the Python progr typically set on the command line PyGetProgramName sys.argv[0] Returns the name of the Python progra name set through PySetProgramNam command line; should be supplied with arguments (argc and argv), the numb arguments, and a list of strings, starting PySys_SetArgv sys.argv = list Sets the arguments typically supplied o 0 You'll use many of these functions as you start building embedded Python applications. Also useful is an additional suite of functions that provide information about the Python interpreter itself. I cover this suite later. Page 6 of 24 Embed Python scripting in C applications
7 ibm.com/developerworks Getting embedded instance information Getting information about the Python interpreter is important because you can use it when you execute an application on another platform to determine whether you support the target environment. The functions supported are all part of the Python C API; you can use them just as you could any other part of the C API. Table 2 lists the main functions in this section of the API. Using the functions here, you can gather information about the installation, including version numbers, module paths, and compiler and build information for the Python library used when building the application. Function char* Py_GetPrefix() char* PyGetExecPrefix() char* Py_GetPath() char *Py_GetProgramFullPath() const char* Py_GetVersion() const char* Py_GetPlatform() const char* Py_GetCopyright() const char* Py_GetCompiler() const char* Py_GetBuilderInfo() Description Returns the prefix for the platform-independent files Returns the execution prefix for the installed Python files Returns the list of directories that Python searches for modules (The return value is a string, so directories are separated by colons under UNIX variants and semicolons under Windows.) Returns the full default path to the Python interpreter (Obviously, if you moved interpreter from this location after installation, you won't get the answer you expect.) Returns a string for the current version of the Python library Returns the platform identifier for the current platform Returns the copyright statement Returns the compiler string (name and version of the compiler) used to build the Python library Returns the build information (version and date) of the interpreter You can put all these data together to generate a useful application that reports the information. I show you how to do so in the next panel. Create a Python information application Embed Python scripting in C applications Page 7 of 24
8 ibm.com/developerworks Using the API, both for full embedding and for the information application you're going to build here, is straightforward. Begin by using Py_Initialize() to start the interpreter. I've included a test in the application (by means of Py_IsInitialized()) to ensure that the Python interpreter is ready, then I simply call each information-gathering function to show information about the interpreter. Next, I call Py_Finalize() to close the interpreter and free up the memory before terminating. Technically, this step should occur when the application ends, but it's good practice to close the interpreter deliberately. Here's the final code: #include <Python.h> int main() { printf("getting Python information\n"); Py_Initialize(); if(!py_isinitialized() ) { puts('unable to initialize Python interpreter.'); return 1; } } printf("prefix: %s\nexec Prefix: %s\npython Path: %s\n", Py_GetPrefix(), Py_GetExecPrefix(), Py_GetProgramFullPath()); printf("module Path: %s\n", Py_GetPath()); printf("version: %s\nplatform: %s\ncopyright: %s\n", Py_GetVersion(), Py_GetPlatform(), Py_GetCopyright()); printf("compiler String: %s\nbuild Info: %s\n", Py_GetCompiler(), Py_GetBuildInfo()); Py_Finalize(); return 0; Now, let's look at the process of building the application. Report the information Here is the result of running of the application from the previous panel: $./pyinfo Getting Python information Prefix: /usr Exec Prefix: /usr Python Path: /usr/bin/python Module Path: /usr/lib/python2.2/:/usr/lib/python2.2/plat-linux2:\ /usr/lib/python2.2/lib-tk:/usr/lib/python2.2/lib-dynload Page 8 of 24 Embed Python scripting in C applications
9 ibm.com/developerworks Version: (#1, Oct , 23:33:35) [GCC (Red Hat Linux )] Platform: linux2 Copyright: Copyright (c) 2001, 2002 Python Software Foundation. All Rights Reserved. Copyright (c) 2000 BeOpen.com. All Rights Reserved. Copyright (c) Corporation for National Research Initiatives. All Rights Reserved. Copyright (c) Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved. Compiler String: [GCC (Red Hat Linux )] Build Info: #1, Oct , 23:33:35 Although the application is a simple example of how you can use the Python API, it does show you the basics. To really use the API, however, you need to understand how to translate between different data types. In the next panel, I show you the basic mechanics of translating between Python data types and C data types so that you can exchange information. Translating between data types Converting between C and Python formats relies on a solution similar to what C uses for printing and "reading" variables through the printf and scanf functions. Within the Python API, the PyArg_Parse* suite of functions extracts information from objects within the Python original into local C types. For example, you can use the PyArg_ParseTuple function to extract information from a tuple of values (that is, a fixed list of values) -- a frequent return type from many functions. You could extract a couple of values from such a tuple by using: float radius, height; PyArg_ParseTuple(args,"ff",&radius,&height); The first argument is the Python tuple object from which you want to extract values. The second argument is the format to use when extracting values. In this case, I've used the letter f twice to signify two floating point values. The last two arguments are the pointers to the C variables into which I want the data loaded. You can also compose Python objects by using the Py_BuildValue function. Try creating a Python floating point variable from a C float variable. The code looks like this: PyObject pyfloat; float pi = ; pyfloat = Py_BuildValue("f",pi); Embed Python scripting in C applications Page 9 of 24
10 ibm.com/developerworks Note how I've used the same letter f to signify a floating point value. And instead of extracting the data, the function returns a Python object (using the special C type PyObject) made up from the supplied value. The format string is used when creating and extracting values; it follows a format similar to printf. You can get a more detailed list from the Python documentation (see the Resources (#resources) section at the end of this tutorial for more information), but the main format types and their corresponding data type are listed in Table 3. Format Python Type C type Notes s String char * Null terminates string i Integer int f Float float (items) Tuple Variable list Where items is a list of appropriate format specifiers [items] Array Variable list C to Python only, where items is a list of format specifiers [items] Dictionary Variable list C to Python only, where items is a list of format specifiers (Specify the key first, then the value.) Page 10 of 24 Embed Python scripting in C applications
11 ibm.com/developerworks Section 4. Build embedded applications Use Distutils to build an application Compiling an embedded application is complicated -- not because there are many steps, but because you need to tell your C compiler where to find the necessary header files and libraries required to build the final application. The problem is that this information isn't standardized across platforms or even across individual machines of the same platform: The user or administrator can install Python anywhere. And as if that weren't complicated enough, individual installations can use a range of command-line options during the build process that must be duplicated when building any application that relies on the Python libraries. Fortunately, help is at hand in the guise of the distutils system and, in particular, distutils.sysconfig, which provides information about the current Python installation. You can use these tools to get information about the Python header files and libraries necessary for actually building the application. You need three main pieces of information: The options to the C compiler The list of include directories for header files The list of libraries You can extract the information by using the following statement: distutils.sysconfig.get_config_var(opt) For example, the list of libraries that you need to build into an application is stored in several different options. The system libraries reside in SYSLIBS, the libraries that the core Python interpreter requires reside in LIBS, and those libraries that many Python modules require reside in MODLIBS. Because these libraries can also appear in locations other than the default location, you need to determine the library directories, which reside in LIBDIR. This last option is actually a space-separated list of library directories; for inclusion on the command line, you need to prefix each directory with -L. The include directories, which reside in INCLDIRSTOMAKE, need the same treatment but with an -I prefix to identify them as include rather than library directories. Daunted? There's a simpler way. Write a script to create a Makefile To make the build process easier, I've written a script (which I've been using for many years) to build a simple Makefile using the information that the distutils tool provides. You can use the resulting Makefile in combination with a suitable make tool to compile nearly any embedded application. Here's my simple Python script, which I Embed Python scripting in C applications Page 11 of 24
12 ibm.com/developerworks call pymkfile.py: #!/usr/local/bin/python import distutils.sysconfig import string, sys configopts = {} maketemplate = """ PYLIB=%(pythonlib)s PYINC=-I%(pythoninc)s LIBS=%(pylibs)s OPTS=%(pyopt)s PROGRAMS=%(programs)s all: $(PROGRAMS) """ configopts['pythonlib'] = distutils.sysconfig.get_config_var('libpl') \ + '/' + \ distutils.sysconfig.get_config_var('library') configopts['pythoninc'] = '' configopts['pylibs'] = '' for dir in string.split(distutils.sysconfig.get_config_var('incldirstomake')): configopts['pythoninc'] += '-I%s ' % (dir,) for dir in string.split(distutils.sysconfig.get_config_var('libdir')): configopts['pylibs'] += '-L%s ' % (dir,) configopts['pylibs'] += distutils.sysconfig.get_config_var('modlibs') \ + ' ' + \ distutils.sysconfig.get_config_var('libs') \ + ' ' + \ distutils.sysconfig.get_config_var('syslibs') configopts['pyopt'] = distutils.sysconfig.get_config_var('opt') targets = '' for arg in sys.argv[1:]: targets += arg + ' ' configopts['programs'] = targets print maketemplate % configopts for arg in sys.argv[1:]: print "%s: %s.o\n\tgcc %s.o $(LIBS) $(PYLIB) -o %s" \ % (arg, arg, arg, arg) print "%s.o: %s.c\n\tgcc %s.c -c $(PYINC) $(OPTS)" \ % (arg, arg, arg) print "clean:\n\trm -f $(PROGRAMS) *.o *.pyc core" It's probably best not to worry too much about the content of this script. Aside from a small amount of initial preamble to extract, then build up some information, the bulk of the script is given over to writing out a Makefile with the various pieces of information Page 12 of 24 Embed Python scripting in C applications
13 ibm.com/developerworks embedded at suitable places. I show you how to use this script in the next panel. Create a Makefile To use the pymkfile.py script, provide the name of the source file you want to build (without its extension). For example, to build a Makefile to compile the Python information application I created in the previous section, you would run the command: $./pymkfile.py pyinfo >Makefile The result, on the Linux x86 host that I'm using, is the Makefile below: PYLIB=/usr/lib/python2.2/config/libpython2.2.a PYINC=-I-I/usr/include -I/usr/include -I/usr/include/python2.2 -I/usr/include/python2.2 LIBS=-L/usr/lib -ldl -lpthread -lutil -lm OPTS=-DNDEBUG -O2 -g -pipe -march=i386 -mcpu=i686 -D_GNU_SOURCE -fpic PROGRAMS=pyinfo all: $(PROGRAMS) pyinfo: pyinfo.o gcc pyinfo.o $(LIBS) $(PYLIB) -o pyinfo pyinfo.o: pyinfo.c gcc pyinfo.c -c $(PYINC) $(OPTS) clean: rm -f $(PROGRAMS) *.o *.pyc core To use this Makefile, simply run the make command: $ make gcc pyinfo.c -c -I-I/usr/local/include -I/usr/local/include \ -I/usr/local/include/python2.1 -I/usr/local/include/python2.1 \ -g -O2 -W all -Wstrict-prototypes gcc pyinfo.o -L/usr/local/lib -lpthread -lsocket -lnsl -ldl \ -lthread -lm /usr/local/lib/python2.1/config/libpython2.1.a \ -o pyinfo Incidentally, you can provide the names of multiple sources to the pymkfile.py script. The script will produce multiple targets to build each source individually. For example, to build a Makefile for the pyinfo example and the upcoming pystring example, you would type: $./pymkfile.py pyinfo pystring>makefile To compile either application individually, specify the name of the application (target) to make: Embed Python scripting in C applications Page 13 of 24
14 ibm.com/developerworks $ make pystring To simply rebuild all the applications whose source files have changed, type make. Now, let's look at a real embedded Python example. Execute an arbitrary string The simplest method of embedding Python code is to use the PyRun_SimpleString() function. This function sends a single line of code to the interpreter. Because the interpreter is persistent, it's like typing the individual lines in an interactive Python session, which means that you can execute new lines to the interpreter by calling PyRun_SimpleString with each line of code. For example, the following code runs a simple Python program to split and reassemble a string: #include <Python.h> int main() { printf("string execution\n"); Py_Initialize(); PyRun_SimpleString("import string"); PyRun_SimpleString("words = string.split('rod jane freddy')"); PyRun_SimpleString("print string.join(words,', ')"); Py_Finalize(); return 0; } You can see that the basic structure is simple. You have the initialize and finalize steps, and embedded between are the calls to the Python interpreter. To compile the program, copy the code and save it to a file called pystring.c. First, use the script to build a suitable Makefile: $ pymkfile.py pystring > Makefile Now, run make to actually build the code. After the final application has been created, run the application to see the results: $./pystring String execution rod, jane, freddy You've just executed a simple bit of Python code by using a C wrapper. You could use the same basic technique to perform many different tasks that use Python embedded in an application. The only obvious limitation is that, in essence, the two components are separate. There's no communication between the embedded Python interpreter and the host C application. So, you gave the interpreter some code and it executed and printed it out; note how Page 14 of 24 Embed Python scripting in C applications
15 ibm.com/developerworks you didn't have to take the output from the interpreter, then print it: The interpreter sent the information directly to the standard output. Now, let's move on to more realistic embedding situations by integrating with the Python object and class system to execute arbitrary code from external modules. Embed Python scripting in C applications Page 15 of 24
16 ibm.com/developerworks Section 5. Advanced embedding techniques Integrating with objects In the previous section, you learned how you can execute strings through an embedded interpreter. These strings are executed without any further intervention or integration. In fact, you could have either run the code directly through Python or by used the PyRun_File() function: You wouldn't have recognized the difference. However, if you want to work with Python code and pass information to and from the Python interpreter to process information from the host application, you need to work with the interpreter in a different way. You do so by working with Python objects. In essence, everything within Python is an object of some kind. Through objects, you can extract attributes and use a consistent referencing format for everything from modules to variables. The object interface within embedded code uses the object structure to access entities in the system directly and execute code. For the system to work, you need to use the Python/C data-exchange system you saw in the first section as well as additional functions from the API that will create a suitable environment and provide an interface to the interpreter in a way that enables you to use objects directly. First, you need to start with a module. Use a simple module that can reverse a variety of data types, such as strings or lists, or create the inverse of numbers and swap keys for values in a dictionary. Here, you can see the reverse module: def rstring(s): i = len(s)-1 t = '' while(i > -1): t += s[i] i -= 1 return t def rnum(i): return 1.0/float(i) def rlist(l): l.reverse() return l def rdict(d): e = {} for k in d.keys(): e[d[k]] = k return e To use a single function from within an embedded application, you need to access a reference to an object. The PyObject_GetAttrString() function gets an objects attribute by name by accessing the appropriate attribute table. All you have to do is supply the host object and the name of the attribute. In this case, you want to access a function, so choose rstring, which is actually an attribute of the reverse module. Page 16 of 24 Embed Python scripting in C applications
17 ibm.com/developerworks Call an object You're going to use the rstring function by supplying it with a string to be reversed, then print the result. Both the source string and the return value will be supplied and printed by the host C application. To exchange information with the function in this way, perform the following steps: 1. Import the module that contains the function. (Remember the loaded module object.) 2. Get the reference to the function by accessing the attribute of the module. 3. Build the Python variable that you'll supply to the function. 4. Call the function. 5. Convert the returned Python object back into a C variable. Use this sequence to start building the final code. First, load the module. Rather than using a PyRun_* statement, use the PyImport_ImportModule() function. This function accepts a module name and returns a Python object (in this case, a module object). You'll need this object when you want to pick a function from that module. The fragment of code looks like this: PyObject *mymod = NULL; mymod = PyImport_ImportModule("reverse"); Now, using that module, pick the rstring function from the module by accessing the corresponding attribute that points to that function. Again, the return value will be a Python object. To get your function object, you use the following statement: PyObject *strfunc = NULL; strfunc = PyObject_GetAttrString(mymod, "rstring"); The resulting object is a function reference that you can use to call the function from within the C wrapper. Now, you need to build the argument list. There's only one argument to this function, so you can simply call Py_BuildValue to convert a string. Using a static string, the code looks like this: PyObject *strargs = NULL; strargs = PyBuildValue("(s)", "Hello World"); Note that you could just as easily have used an argument from the command line by supplying this fragment, instead: strargs = PyBuildValue("(s)", argv[1]); The call to the function uses PyEval_CallObject, which accepts a suitable code object (the object you extracted through attributes earlier in this section) and the arguments (which you've just built): Embed Python scripting in C applications Page 17 of 24
18 ibm.com/developerworks PyObject *strret = NULL; PyEval_CallObject(strfunc, strargs); Finally, the rstring function returns the string in its reversed format. You need to trap that return value, convert it back to a C variable, and print it out: char *cstrret = NULL; PyArg_Parse(strret, "s", &cstrret); printf("reversed string: %s\n",cstrret); Putting all that together by hand is challenging, so let's look at the final C source. Calling the reversal functions Here's the final code. #include <Python.h> int main() { PyObject *strret, *mymod, *strfunc, *strargs; char *cstrret; } Py_Initialize(); mymod = PyImport_ImportModule("reverse"); strfunc = PyObject_GetAttrString(mymod, "rstring"); strargs = Py_BuildValue("(s)", "Hello World"); strret = PyEval_CallObject(strfunc, strargs); PyArg_Parse(strret, "s", &cstrret); printf("reversed string: %s\n", cstrret); Py_Finalize(); return 0; If you compile the code, then run the application, you should get a suitably reversed string: $./pyreverse Reversed string: dlrow olleh If you have problems getting the example to work, make sure that the reverse.py module is in the Python interpreter's path. (This path is probably the same -- that is, the current -- directory.) Make sure you update the value of the PYTHONPATH environment variable accordingly. The final method for integrating with Python from within C is through the class/object Page 18 of 24 Embed Python scripting in C applications
19 ibm.com/developerworks system, a common requirement with an object-based language. Embed Python scripting in C applications Page 19 of 24
20 ibm.com/developerworks Section 6. Working with Python classes The basic class Because Python is an object-oriented language, most of the interaction with Python will often be with Python classes and objects. To use a class within an embedded application, you follow more or less the same sequence as before: You load the module, create a suitable object, use PyObject_GetAttrString to get the reference to the object or its methods, then execute the method as before. For the example I provide here, you're going to use a simple module for converting a given Celsius value into Fahrenheit: class celsius: def init (self, degrees): self.degrees = degrees def farenheit(self): return ((self.degrees*9.0)/5.0)+32.0 A simple use of this class within Python might look like this: import celsius temp = celsius.celsius(100) print temp.farenheit() Now, let's look at an embedded Python example that performs the same basic sequence. The embedded version The embedded version performs the same operation and follows the same basic sequence as the earlier object example. This example also includes error checking at each stage so that you can see how to verify the progress of each step. #include <Python.h> /* Create a function to handle errors when they occur */ void error(char errstring) { printf("%s\n",errstring); exit(1); } int main() { /* Set up the variables to hold methods, functions and class instances. farenheit will hold our return value */ PyObject *ret, *mymod, *class, *method, *args, *object; float farenheit; Py_Initialize(); Page 20 of 24 Embed Python scripting in C applications
21 ibm.com/developerworks /* Load our module */ mymod = PyImport_ImportModule("celsius"); /* If we dont get a Python object back there was a problem */ if (mymod == NULL) error("can't open module"); /* Find the class */ class = PyObject_GetAttrString(mymod, "celsius"); /* If found the class we can dump mymod, since we won't use it again */ Py_DECREF(mymod); /* Check to make sure we got an object back */ if (class == NULL) { Py_DECREF(class); error("can't find class"); } /* Build the argument call to our class - these are the arguments that will be supplied when the object is created */ args = Py_BuildValue("(f)", 100.0); if (args == NULL) { Py_DECREF(args); error("can't build argument list for class instance"); } /* Create a new instance of our class by calling the class with our argument list */ object = PyEval_CallObject(class, args); if (object == NULL) { Py_DECREF(object); error("can't create object instance"); } /* Decrement the argument counter as we'll be using this again */ Py_DECREF(args); /* Get the object method - note we use the object as the object from which we access the attribute by name, not the class */ method = PyObject_GetAttrString(object, "farenheit"); if (method == NULL) { Py_DECREF(method); error("can't find method"); } /* Decrement the counter for our object, since we now just need the method reference */ Py_DECREF(object); Embed Python scripting in C applications Page 21 of 24
22 ibm.com/developerworks /* Build our argument list - an empty tuple because there aren't any arguments */ args = Py_BuildValue("()"); if (args == NULL) { Py_DECREF(args); error("can't build argument list for method call"); } /* Call our object method with arguments */ ret = PyEval_CallObject(method,args); if (ret == NULL) { Py_DECREF(ret); error("couldn't call method"); } /* Convert the return value back into a C variable and display it */ PyArg_Parse(ret, "f", &farenheit); printf("farenheit: %f\n", farenheit); /* Kill the remaining objects we don't need */ Py_DECREF(method); Py_DECREF(ret); /* Close off the interpreter and terminate */ Py_Finalize(); return 0; } One key difference between this example and the previous examples is that in addition to the error check, you also free up Python objects that you've created but no longer need. However, you don't have to free the objects directly: Instead, you tell Python through the Py_DECREF function to decrement the reference count for the object. In Python (and other languages), when the reference count to a variable reaches zero, the object is automatically deleted as part of the garbage-collection process. If you compile and run the example, you should get output identical to the earlier, Python-based version: $./pycelsius Farenheit: Page 22 of 24 Embed Python scripting in C applications
23 ibm.com/developerworks Section 7. Summary and resources Summary In this tutorial, you've seen the basic process for embedding Python scripts in your C applications. You can use various embedding methods shown here for different types of solutions. The simple string execution isn't that useful unless you want to be able to run a piece of Python code from within your C application that performs a specific task without using exec or a similar command -- a common requirement for embedded hardware, for example. With the object- and class-based versions, you have more detailed connectivity between the Python and C components of the application. Using these methods, you can make the best of both C and Python in a final application -- for example, using Python for the mathematical components (something it's very good at) but with the fixed distributable format of a C-based application. You should be able to adapt the examples in this tutorial to your own needs and requirements. Resources You can find more information about embedding Python in the online documentation at Embedding Python in Another Application ( For more information about the Python-to-C translation functions for converting data types and the formats available, check out the The Py_BuildValue() Function documentation page on the Python Web site. The examples in this tutorial were taken from Chapter 27 of Python: The Complete Reference ( by Martin C. Brown. You can also find the source code for all the examples in the book, including those used here, on my homepage, MCslp.com ( Feedback Please let us know whether this tutorial was helpful to you and how we could make it better. We'd also like to hear about other tutorial topics you'd like developerworks to cover. For questions about the content of this tutorial, contact the author, Martin C. Brown, at [email protected]. Colophon This tutorial was written entirely in XML, using the developerworks Toot-O-Matic tutorial Embed Python scripting in C applications Page 23 of 24
24 ibm.com/developerworks generator. The open source Toot-O-Matic tool is an XSLT stylesheet and several XSLT extension functions that convert an XML file into a number of HTML pages, a zip file, JPEG heading graphics, and two PDF files. Our ability to generate multiple text and binary formats from a single source file illustrates the power and flexibility of XML. (It also saves our production team a great deal of time and effort.) For more information about the Toot-O-Matic, visit www-106.ibm.com/developerworks/xml/library/x-toot/. Page 24 of 24 Embed Python scripting in C applications
Build a GCC-based cross compiler for Linux
Build a GCC-based cross compiler for Linux Table of contents If you're viewing this document online, you can click any of the topics below to link directly to that section. 1. Before you start... 2 2.
Informatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
Sources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
Chapter 1: Getting Started
Chapter 1: Getting Started Every journey begins with a single step, and in ours it's getting to the point where you can compile, link, run, and debug C++ programs. This depends on what operating system
How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)
TN203 Porting a Program to Dynamic C Introduction Dynamic C has a number of improvements and differences compared to many other C compiler systems. This application note gives instructions and suggestions
We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.
LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.
CS 1133, LAB 2: FUNCTIONS AND TESTING http://www.cs.cornell.edu/courses/cs1133/2015fa/labs/lab02.pdf
CS 1133, LAB 2: FUNCTIONS AND TESTING http://www.cs.cornell.edu/courses/cs1133/2015fa/labs/lab02.pdf First Name: Last Name: NetID: The purpose of this lab is to help you to better understand functions:
Computer Systems II. Unix system calls. fork( ) wait( ) exit( ) How To Create New Processes? Creating and Executing Processes
Computer Systems II Creating and Executing Processes 1 Unix system calls fork( ) wait( ) exit( ) 2 How To Create New Processes? Underlying mechanism - A process runs fork to create a child process - Parent
Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
Outline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage
Outline 1 Computer Architecture hardware components programming environments 2 Getting Started with Python installing Python executing Python code 3 Number Systems decimal and binary notations running
Virtuozzo Virtualization SDK
Virtuozzo Virtualization SDK Programmer's Guide February 18, 2016 Copyright 1999-2016 Parallels IP Holdings GmbH and its affiliates. All rights reserved. Parallels IP Holdings GmbH Vordergasse 59 8200
Using EDA Databases: Milkyway & OpenAccess
Using EDA Databases: Milkyway & OpenAccess Enabling and Using Scripting Languages with Milkyway and OpenAccess Don Amundson Khosro Khakzadi 2006 LSI Logic Corporation 1 Outline History Choice Of Scripting
Channel Access Client Programming. Andrew Johnson Computer Scientist, AES-SSG
Channel Access Client Programming Andrew Johnson Computer Scientist, AES-SSG Channel Access The main programming interface for writing Channel Access clients is the library that comes with EPICS base Written
B&K Precision 1785B, 1786B, 1787B, 1788 Power supply Python Library
B&K Precision 1785B, 1786B, 1787B, 1788 Power supply Python Library Table of Contents Introduction 2 Prerequisites 2 Why a Library is Useful 3 Using the Library from Python 6 Conventions 6 Return values
The programming language C. sws1 1
The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan
Lab 2 : Basic File Server. Introduction
Lab 2 : Basic File Server Introduction In this lab, you will start your file system implementation by getting the following FUSE operations to work: CREATE/MKNOD, LOOKUP, and READDIR SETATTR, WRITE and
1. To start Installation: To install the reporting tool, copy the entire contents of the zip file to a directory of your choice. Run the exe.
CourseWebs Reporting Tool Desktop Application Instructions The CourseWebs Reporting tool is a desktop application that lets a system administrator modify existing reports and create new ones. Changes to
CS 103 Lab Linux and Virtual Machines
1 Introduction In this lab you will login to your Linux VM and write your first C/C++ program, compile it, and then execute it. 2 What you will learn In this lab you will learn the basic commands and navigation
SQLITE C/C++ TUTORIAL
http://www.tutorialspoint.com/sqlite/sqlite_c_cpp.htm SQLITE C/C++ TUTORIAL Copyright tutorialspoint.com Installation Before we start using SQLite in our C/C++ programs, we need to make sure that we have
CP Lab 2: Writing programs for simple arithmetic problems
Computer Programming (CP) Lab 2, 2015/16 1 CP Lab 2: Writing programs for simple arithmetic problems Instructions The purpose of this Lab is to guide you through a series of simple programming problems,
Hadoop Streaming. Table of contents
Table of contents 1 Hadoop Streaming...3 2 How Streaming Works... 3 3 Streaming Command Options...4 3.1 Specifying a Java Class as the Mapper/Reducer... 5 3.2 Packaging Files With Job Submissions... 5
How to Write a Simple Makefile
Chapter 1 CHAPTER 1 How to Write a Simple Makefile The mechanics of programming usually follow a fairly simple routine of editing source files, compiling the source into an executable form, and debugging
The C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
iphone Objective-C Exercises
iphone Objective-C Exercises About These Exercises The only prerequisite for these exercises is an eagerness to learn. While it helps to have a background in object-oriented programming, that is not a
Simple Document Management Using VFP, Part 1 Russell Campbell [email protected]
Seite 1 von 5 Issue Date: FoxTalk November 2000 Simple Document Management Using VFP, Part 1 Russell Campbell [email protected] Some clients seem to be under the impression that they need to
CSC230 Getting Starting in C. Tyler Bletsch
CSC230 Getting Starting in C Tyler Bletsch What is C? The language of UNIX Procedural language (no classes) Low-level access to memory Easy to map to machine language Not much run-time stuff needed Surprisingly
Installing Java. Table of contents
Table of contents 1 Jargon...3 2 Introduction...4 3 How to install the JDK...4 3.1 Microsoft Windows 95... 4 3.1.1 Installing the JDK... 4 3.1.2 Setting the Path Variable...5 3.2 Microsoft Windows 98...
Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)
Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating
Cross-platform event logging in Object Pascal
Cross-platform event logging in Object Pascal Micha el Van Canneyt June 24, 2007 1 Introduction Often, a program which works in the background or sits in the windows system tray needs to write some diagnostic
INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011
INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 1 Goals of the Lecture Present an introduction to Objective-C 2.0 Coverage of the language will be INCOMPLETE
Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas
CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage
Why you shouldn't use set (and what you should use instead) Matt Austern
Why you shouldn't use set (and what you should use instead) Matt Austern Everything in the standard C++ library is there for a reason, but it isn't always obvious what that reason is. The standard isn't
Tutorial. Reference http://www.openflowswitch.org/foswiki/bin/view/openflow/mininetgettingstarted for more thorough Mininet walkthrough if desired
Setup Tutorial Reference http://www.openflowswitch.org/foswiki/bin/view/openflow/mininetgettingstarted for more thorough Mininet walkthrough if desired Necessary Downloads 1. Download VM at http://www.cs.princeton.edu/courses/archive/fall10/cos561/assignments/cos561tutorial.zip
An Incomplete C++ Primer. University of Wyoming MA 5310
An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages
Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, 2008. 1 Introduction 1. 2 Invoking Shell Scripts 2
Unix Shell Scripts Norman Matloff July 30, 2008 Contents 1 Introduction 1 2 Invoking Shell Scripts 2 2.1 Direct Interpretation....................................... 2 2.2 Indirect Interpretation......................................
Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
Computer Programming In QBasic
Computer Programming In QBasic Name: Class ID. Computer# Introduction You've probably used computers to play games, and to write reports for school. It's a lot more fun to create your own games to play
Hello World Portlet Rendered with JSP for WebSphere Portal Version 4.1
1 of 11 16.10.2002 11:41 Hello World Portlet Rendered with JSP for WebSphere Portal Version 4.1 Table of Contents Creating the directory structure Creating the Java code Compiling the code Creating the
1001ICT Introduction To Programming Lecture Notes
1001ICT Introduction To Programming Lecture Notes School of Information and Communication Technology Griffith University Semester 2, 2015 1 3 A First MaSH Program In this section we will describe a very
TSPrint - Usage Guide. Usage Guide. TerminalWorks TSPrint Usage Guide. [email protected]
Usage Guide TerminalWorks TSPrint Usage Guide Page 1 Contents TSPrint license system... 4 Software requirements... 5 Installation... 6 TSPrint client installation... 6 TSPrint server installation... 10
DB2 Security. Presented by DB2 Developer Domain http://www7b.software.ibm.com/dmdd/
DB2 Security http://www7b.software.ibm.com/dmdd/ Table of Contents If you're viewing this document online, you can click any of the topics below to link directly to that section. 1. Introduction... 2 2.
Creating a Java application using Perfect Developer and the Java Develo...
1 of 10 15/02/2010 17:41 Creating a Java application using Perfect Developer and the Java Development Kit Introduction Perfect Developer has the facility to execute pre- and post-build steps whenever the
Add an Audit Trail to your Access Database
Add an to your Access Database Published: 22 April 2013 Author: Martin Green Screenshots: Access 2010, Windows 7 For Access Versions: 2003, 2007, 2010 About This Tutorial My Access tutorials are designed
University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python
Introduction Welcome to our Python sessions. University of Hull Department of Computer Science Wrestling with Python Week 01 Playing with Python Vsn. 1.0 Rob Miles 2013 Please follow the instructions carefully.
Illustration 1: Diagram of program function and data flow
The contract called for creation of a random access database of plumbing shops within the near perimeter of FIU Engineering school. The database features a rating number from 1-10 to offer a guideline
Lecture 5: Java Fundamentals III
Lecture 5: Java Fundamentals III School of Science and Technology The University of New England Trimester 2 2015 Lecture 5: Java Fundamentals III - Operators Reading: Finish reading Chapter 2 of the 2nd
ESPResSo Summer School 2012
ESPResSo Summer School 2012 Introduction to Tcl Pedro A. Sánchez Institute for Computational Physics Allmandring 3 D-70569 Stuttgart Germany http://www.icp.uni-stuttgart.de 2/26 Outline History, Characteristics,
Part II. Managing Issues
Managing Issues Part II. Managing Issues If projects are the most important part of Redmine, then issues are the second most important. Projects are where you describe what to do, bring everyone together,
Source Code Translation
Source Code Translation Everyone who writes computer software eventually faces the requirement of converting a large code base from one programming language to another. That requirement is sometimes driven
Smooks Dev Tools Reference Guide. Version: 1.1.0.GA
Smooks Dev Tools Reference Guide Version: 1.1.0.GA Smooks Dev Tools Reference Guide 1. Introduction... 1 1.1. Key Features of Smooks Tools... 1 1.2. What is Smooks?... 1 1.3. What is Smooks Tools?... 2
Lab 1 Beginning C Program
Lab 1 Beginning C Program Overview This lab covers the basics of compiling a basic C application program from a command line. Basic functions including printf() and scanf() are used. Simple command line
Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11
Dalhousie University CSCI 2132 Software Development Winter 2015 Lab 7, March 11 In this lab, you will first learn how to use pointers to print memory addresses of variables. After that, you will learn
Embedded Software Development
Linköpings Tekniska Högskola Institutionen för Datavetanskap (IDA), Software and Systems (SaS) TDDI11, Embedded Software 2010-04-22 Embedded Software Development Host and Target Machine Typical embedded
System Security Fundamentals
System Security Fundamentals Alessandro Barenghi Dipartimento di Elettronica, Informazione e Bioingegneria Politecnico di Milano alessandro.barenghi - at - polimi.it April 28, 2015 Lesson contents Overview
4PSA DNS Manager 3.7.0. Translator's Manual
4PSA DNS Manager 3.7.0 Translator's Manual For more information about 4PSA DNS Manager, check: http://www.4psa.com Copyrights 2002-2010 Rack-Soft, Inc. Translator's Manual Manual Version 48807.9 at 2010/03/10
MS Outlook to Unix Mailbox Conversion mini HOWTO
Table of Contents MS Outlook to Unix Mailbox Conversion mini HOWTO...1 Greg Lindahl, [email protected] 1. Introduction...1 2. Converting using Mozilla Mail...1 3. Converting using IMAP...1 1. Introduction...1
QaTraq Pro Scripts Manual - Professional Test Scripts Module for QaTraq. QaTraq Pro Scripts. Professional Test Scripts Module for QaTraq
QaTraq Pro Scripts Professional Test Scripts Module for QaTraq QaTraq Professional Modules QaTraq Professional Modules are a range of plug in modules designed to give you even more visibility and control
CISC 181 Project 3 Designing Classes for Bank Accounts
CISC 181 Project 3 Designing Classes for Bank Accounts Code Due: On or before 12 Midnight, Monday, Dec 8; hardcopy due at beginning of lecture, Tues, Dec 9 What You Need to Know This project is based on
Eventia Log Parsing Editor 1.0 Administration Guide
Eventia Log Parsing Editor 1.0 Administration Guide Revised: November 28, 2007 In This Document Overview page 2 Installation and Supported Platforms page 4 Menus and Main Window page 5 Creating Parsing
Python Lists and Loops
WEEK THREE Python Lists and Loops You ve made it to Week 3, well done! Most programs need to keep track of a list (or collection) of things (e.g. names) at one time or another, and this week we ll show
Assignment 4 CPSC 217 L02 Purpose. Important Note. Data visualization
Assignment 4 CPSC 217 L02 Purpose You will be writing a Python program to read data from a file and visualize this data using an external drawing tool. You will structure your program using modules and
Chapter 13 Storage classes
Chapter 13 Storage classes 1. Storage classes 2. Storage Class auto 3. Storage Class extern 4. Storage Class static 5. Storage Class register 6. Global and Local Variables 7. Nested Blocks with the Same
Moving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
Exercise 4 Learning Python language fundamentals
Exercise 4 Learning Python language fundamentals Work with numbers Python can be used as a powerful calculator. Practicing math calculations in Python will help you not only perform these tasks, but also
Parallelization: Binary Tree Traversal
By Aaron Weeden and Patrick Royal Shodor Education Foundation, Inc. August 2012 Introduction: According to Moore s law, the number of transistors on a computer chip doubles roughly every two years. First
Java programming for C/C++ developers
Skill Level: Introductory Scott Stricker ([email protected]) Developer IBM 28 May 2002 This tutorial uses working code examples to introduce the Java language to C and C++ programmers. Section 1. Getting
Image Management Suite. Mini Thesis. Roland Foster. Supervisors: Mr. Mehrdad Ghaziasgar and Mr. James Connan. B.Sc. Honours
Image Management Suite Mini Thesis Roland Foster 2916282 Supervisors: Mr. Mehrdad Ghaziasgar and Mr. James Connan B.Sc. Honours Department of Computer Science 2012 Acknowledgements I would like to thank
Mail. Add or delete contacts. Chapter 3: Manage Contacts. Table of Contents
Table of Contents Add or delete contacts Find your contacts Create Contacts Automatic contacts Edit or change contacts Search for contacts Print your contacts Upload existing contacts and groups Import
Hands-On UNIX Exercise:
Hands-On UNIX Exercise: This exercise takes you around some of the features of the shell. Even if you don't need to use them all straight away, it's very useful to be aware of them and to know how to deal
Zenoss Resource Manager ZenUp Installation and Administration
Zenoss Resource Manager ZenUp Installation and Administration Zenoss Resource Manager ZenUp Installation and Administration Copyright 2014 Zenoss, Inc. All rights reserved. Redistribution or duplication
Computer Programming Tutorial
Computer Programming Tutorial COMPUTER PROGRAMMING TUTORIAL by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Computer Prgramming Tutorial Computer programming is the act of writing computer
CLC Server Command Line Tools USER MANUAL
CLC Server Command Line Tools USER MANUAL Manual for CLC Server Command Line Tools 2.5 Windows, Mac OS X and Linux September 4, 2015 This software is for research purposes only. QIAGEN Aarhus A/S Silkeborgvej
PHP Tutorial From beginner to master
PHP Tutorial From beginner to master PHP is a powerful tool for making dynamic and interactive Web pages. PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
Zenoss Core ZenUp Installation and Administration
Zenoss Core ZenUp Installation and Administration Zenoss Core ZenUp Installation and Administration Copyright 2014 Zenoss, Inc. All rights reserved. Redistribution or duplication of any portion of this
Outside In Image Export Technology SDK Quick Start Guide
Reference: 2009/02/06-8.3 Outside In Image Export Technology SDK Quick Start Guide This document provides an overview of the Outside In Image Export Software Developer s Kit (SDK). It includes download
First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
Hypercosm. Studio. www.hypercosm.com
Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks
7 Why Use Perl for CGI?
7 Why Use Perl for CGI? Perl is the de facto standard for CGI programming for a number of reasons, but perhaps the most important are: Socket Support: Perl makes it easy to create programs that interface
NRPE Documentation CONTENTS. 1. Introduction... a) Purpose... b) Design Overview... 2. Example Uses... a) Direct Checks... b) Indirect Checks...
Copyright (c) 1999-2007 Ethan Galstad Last Updated: May 1, 2007 CONTENTS Section 1. Introduction... a) Purpose... b) Design Overview... 2. Example Uses... a) Direct Checks... b) Indirect Checks... 3. Installation...
ODBC Driver User s Guide. Objectivity/SQL++ ODBC Driver User s Guide. Release 10.2
ODBC Driver User s Guide Objectivity/SQL++ ODBC Driver User s Guide Release 10.2 Objectivity/SQL++ ODBC Driver User s Guide Part Number: 10.2-ODBC-0 Release 10.2, October 13, 2011 The information in this
FileMaker Server 9. Custom Web Publishing with PHP
FileMaker Server 9 Custom Web Publishing with PHP 2007 FileMaker, Inc. All Rights Reserved. FileMaker, Inc. 5201 Patrick Henry Drive Santa Clara, California 95054 FileMaker is a trademark of FileMaker,
Drawing Text with SDL
Drawing Text with SDL Note: This tutorial assumes that you already know how to display a window and draw a sprite with SDL. Setting Up the SDL TrueType Font Library To display text with SDL, you need the
Continuous Integration Part 2
1 Continuous Integration Part 2 This blog post is a follow up to my blog post Continuous Integration (CI), in which I described how to execute test cases in Code Tester (CT) in a CI environment. What I
Linux Driver Devices. Why, When, Which, How?
Bertrand Mermet Sylvain Ract Linux Driver Devices. Why, When, Which, How? Since its creation in the early 1990 s Linux has been installed on millions of computers or embedded systems. These systems may
RTI Database Integration Service. Getting Started Guide
RTI Database Integration Service Getting Started Guide Version 5.2.0 2015 Real-Time Innovations, Inc. All rights reserved. Printed in U.S.A. First printing. June 2015. Trademarks Real-Time Innovations,
8.5. <summary>...26 9. Cppcheck addons...27 9.1. Using Cppcheck addons...27 9.1.1. Where to find some Cppcheck addons...27 9.2.
Cppcheck 1.72 Cppcheck 1.72 Table of Contents 1. Introduction...1 2. Getting started...2 2.1. First test...2 2.2. Checking all files in a folder...2 2.3. Excluding a file or folder from checking...2 2.4.
Getting Started with the Internet Communications Engine
Getting Started with the Internet Communications Engine David Vriezen April 7, 2014 Contents 1 Introduction 2 2 About Ice 2 2.1 Proxies................................. 2 3 Setting Up ICE 2 4 Slices 2
Code::Blocks Student Manual
Code::Blocks Student Manual Lawrence Goetz, Network Administrator Yedidyah Langsam, Professor and Theodore Raphan, Distinguished Professor Dept. of Computer and Information Science Brooklyn College of
Extreme computing lab exercises Session one
Extreme computing lab exercises Session one Michail Basios ([email protected]) Stratis Viglas ([email protected]) 1 Getting started First you need to access the machine where you will be doing all
Running your first Linux Program
Running your first Linux Program This document describes how edit, compile, link, and run your first linux program using: - Gnome a nice graphical user interface desktop that runs on top of X- Windows
Welcome to Introduction to programming in Python
Welcome to Introduction to programming in Python Suffolk One, Ipswich, 4:30 to 6:00 Tuesday Jan 14, Jan 21, Jan 28, Feb 11 Welcome Fire exits Toilets Refreshments 1 Learning objectives of the course An
THE CERN/SL XDATAVIEWER: AN INTERACTIVE GRAPHICAL TOOL FOR DATA VISUALIZATION AND EDITING
THE CERN/SL XDATAVIEWER: AN INTERACTIVE GRAPHICAL TOOL FOR DATA VISUALIZATION AND EDITING Abstract G. Morpurgo, CERN As a result of many years of successive refinements, the CERN/SL Xdataviewer tool has
Java Crash Course Part I
Java Crash Course Part I School of Business and Economics Institute of Information Systems HU-Berlin WS 2005 Sebastian Kolbe [email protected] Overview (Short) introduction to the environment Linux
Enterprise Web Developer : Using the Emprise Javascript Charting Widgets.
Version 4.0.682.2 Background Enterprise Web Developer Using the Emprise Javascript Charting Widgets As of build 4.0.682, Enterprise Web Developer (EWD) includes advanced functionality that allows you to
Visual Basic Programming. An Introduction
Visual Basic Programming An Introduction Why Visual Basic? Programming for the Windows User Interface is extremely complicated. Other Graphical User Interfaces (GUI) are no better. Visual Basic provides
Extreme computing lab exercises Session one
Extreme computing lab exercises Session one Miles Osborne (original: Sasa Petrovic) October 23, 2012 1 Getting started First you need to access the machine where you will be doing all the work. Do this
CSCE 665: Lab Basics. Virtual Machine. Guofei Gu
CSCE 665: Lab Basics Guofei Gu Virtual Machine Virtual Machine: a so?ware implementacon of a programmable machine(client), where the so?ware implementacon is constrained within another computer(host) at
Deploying Microsoft Operations Manager with the BIG-IP system and icontrol
Deployment Guide Deploying Microsoft Operations Manager with the BIG-IP system and icontrol Deploying Microsoft Operations Manager with the BIG-IP system and icontrol Welcome to the BIG-IP LTM system -
Pulse Secure Client. Customization Developer Guide. Product Release 5.1. Document Revision 1.0. Published: 2015-02-10
Pulse Secure Client Customization Developer Guide Product Release 5.1 Document Revision 1.0 Published: 2015-02-10 Pulse Secure, LLC 2700 Zanker Road, Suite 200 San Jose, CA 95134 http://www.pulsesecure.net
