[PyKDE] Posted examples?

Niac Neb niacneb at yahoo.com
Thu May 19 00:16:14 BST 2005


Hello,

Where might I find complete examples?  Is there a WIKI
or site where developers have posted their examples?

As a newbie, even the simplest of examples would be
helpful to me.  Especially those that are complete ...
rather than code snippets.

An example of calling Python from C++ as suggested by
James (below) would be like gold.

Thanks

...

Here's the most maintainable way of calling Python
from C++.  This method keeps your C++ out of your
Python and your Python out of your C++.  As a bonus
feature, if the Python implementation gets too slow,
you can rewrite in C++ without needing to touch any
client code.

//
// iface.h
struct IFoo {
  virtual float wonk(float, float) = 0;
};

//
// iface.sip
%Module foo
class IFoo {
%TypeHeaderCode
#include "iface.h"
%End

public:
  virtual float wonk(float, float) = 0;
};

//
// impl.py
from foo import IFoo

class FooImpl( IFoo ):
    def wonk( self, n1, n2 ):
        return n1 * n2


The only thing left to do in instantiate FooImpl and
hand it back to some C++ function.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




More information about the PyQt mailing list