wie greife ich mit Python auf die c-bibliotheken zu ?

Frank Sonnenburg sonnenbu at informatik.uni-bonn.de
Mon Sep 2 07:37:28 EDT 2002


You can't access directly C++ classes via python. I have made some efforts
to create a python class and instances of it in C, but up to now not really
successfully.

The more easy and so preferrable way is to define a python class in python
and then modify instances of this class in some extension module function,
passing this instance as an argument. To write extension modules, see
extending and embedding python: http://python.org/doc/current/ext/ext.html

Frank



"Oleg Seifert" <misterxx at uni-koblenz.de> schrieb im Newsbeitrag
news:3D7323BB.4070200 at uni-koblenz.de...
> hallo Leute,
>
> könnte vielleicht jemand es mir an einem Beispiel zeigen. Ich habe als
> Attachments zwei kleine Anwendungen dazu geschickt.
>
> danke im Vorraus,
>
> Oleg
>


----------------------------------------------------------------------------
----


>
> /* Dies ist ein Programm in C */
>
> #include <stdio.h>
>
> class person
> {
>   private:
>     char* name;
>     char* geschlecht;
>   public:
>     void set_name(char* n) { name = n; }
>     void set_geschlecht(char* g)  { geschlecht = g; }
>     char* get_name() {return name;}
>     char* get_geschlecht() {return geschlecht;}
> };
>
>
> void main()
> {
> /*
>   person student;
>   student.set_name("Peter");
>   student.set_geschlecht("mannlich");
>   printf("Name : ");
>   printf(student.get_name());
>   printf("\nGeschlecht : ");
>   printf(student.get_geschlecht());
>   printf("\n<<< ende\n");
> */
> }


----------------------------------------------------------------------------
----


> # dies ist ein Python-Programm
>
>
> # hier instanzierung der Klasse person aus punkt.cpp
>
> print "<<< ende"
>





More information about the Python-list mailing list